<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>What about</p>
<p><br>
</p>
<p><span></p>
<div>#(encoding x axis labelAngle) inject: barchart into: [:dict :segment | dict at: segment].</div>
<div><br>
</div>
<div>or even shorter</div>
<div><br>
</div>
<div>#(encoding x axis labelAngle) inject: barchart into: #at:.</div>
</span><br>
<p></p>
<p>?</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von tim Rowledge <tim@rowledge.org><br>
<b>Gesendet:</b> Donnerstag, 2. September 2021 01:33:31<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> [squeak-dev] Json dictionary tree accessing</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">When driving JS libraries from Seaside it is often necessary to build a tree of dictionaries to encode settings - for example, using vega-lite to display charts & graphs.
<br>
<br>
I currently have a very simple case that ends up rather verbose - <br>
        |barchart|<br>
        barchart := Dictionary new.<br>
        barchart<br>
        at: #'$schema' put: '<a href="https://vega.github.io/schema/vega-lite/v5.json">https://vega.github.io/schema/vega-lite/v5.json</a>';<br>
        at: #description put: 'A simple bar chart';<br>
        at: #width put: 'container';<br>
        at: #usermeta put:<br>
                (Dictionary new<br>
                        at: #embedOptions put: <br>
                                (Dictionary new<br>
                                at: #export put: true;<br>
                                at: #compiled put: false;<br>
                                at: #editor put: false;<br>
                                yourself);<br>
                        yourself);<br>
        at: #mark put: <br>
                (Dictionary new<br>
                        at: #type put: #bar;<br>
                        at: #tooltip put: true;<br>
                        yourself);<br>
        at: #encoding put:<br>
                (Dictionary new<br>
                        at: #x<br>
                        put: (Dictionary new<br>
                                        at: #field put: 'label';<br>
                                        at: #type put: #nominal;<br>
                                        at: #axis put: <br>
                                                (Dictionary new<br>
                                                at: #labelAngle put: -45;<br>
                                                yourself);<br>
                                        at: #title put: #Group;<br>
                                        yourself); <br>
                        at: #y<br>
                        put: (Dictionary new<br>
                                        at: #field put: 'value';<br>
                                        at: #type put: #quantitative;<br>
                                        at: #title put: #Value;<br>
                                        yourself);<br>
        yourself);<br>
        at: #height put:'container'.<br>
        ^barchart<br>
<br>
... and that's without any actual data!<br>
<br>
If I want to do something like change the label angle I end up with ugliness like
<br>
        (((chartSpec at: #encoding)<br>
                at: #x)<br>
                at: #axis)<br>
                at:#labelAngle put: axisLabellingAngle.<br>
<br>
I feel sure I've seen this done better but I can't find anything with my current searches. It wouldn't be too hard to implement a method to do #atPath: #(encoding x axis labelAngle) put: thingy but if it's been done cleanly by somebody I'd much rather just
 load it.<br>
<br>
Somebody please point me to the ludicrously obvious answer any idiot should have spotted immediately...<br>
<br>
tim<br>
--<br>
tim Rowledge; tim@rowledge.org; <a href="http://www.rowledge.org/tim">http://www.rowledge.org/tim</a><br>
Strange OpCodes: AG: Add Gibberish<br>
<br>
<br>
<br>
</div>
</span></font>
</body>
</html>