Hi
I am trying to create a bar-chart using an existing SVG graphic - the heights of the rectangles have a value set as an attribute but this is sucessfully over-riden by a style statement which then sets the height to parameter referenced from within the SVG file.
This is all working fine if I pass in hardcoded values, the macro drawGraph2 is working correctly with values b1 to b8 which I used in the previous stage of development, But now I am ready to start prototyping the next stage so for b9 and b10 the value is provided by the macros count80to90 and count90to100 - these use the count filter expression and that is where the problem starts.
<$list filter="[]">
<$let b1=30 b2=75 b3=40 b3=40 b4=40 b5=40 b6=29 b7=41 b8=46 b9=<<count80to90>> b10=<<count90to100>> >
<<drawGraph2>>
</$let>
</$list>
Here is an extract of my SVG
<rect x="40" y="0" width="5" height="66" style=`fill:#123; height:$(b7)$; opacity:50%`/>
<rect x="45" y="0" width="5" height="64" style=`fill:#627; height:$(b8)$; opacity:50%`/>
<rect x="50" y="0" width="5" height="60" style=`fill:#123; height:$(b9)$; opacity:50%`/>
<rect x="55" y="0" width="5" height="60" style=`fill:#627; height:$(b10)$; opacity:50%`/>
<text x="50" y="20"><<b9>><<b10>></text>
The substitutions for b7 b8 work just fine as these were set as variables to hard coded numbers see the first code segment so $(b8)$ is successfully parsed as 46 - all good there!
However b9 and b10 are inconsistent - they do get parsed into numbers as intended in the following debugging text statement which is temporarily added to the SVG
<text x="50" y="20" > <<b9>><<b10>></text>
However b9 and b10 are not parsed correctly in the SVG code for the rectangles, the style statement for height is where the problem lies.
When I inspect the SVG I see that the style statement for the height of rectangles for b9 and b10 remains as a filter expessions from the macros count80to90 and count90to100 whereas what I wanted was the result of evaluating those macros - an integer but what I actually see is the count filter expression.
The following extract from the final rendered SVG contrasts the behaviour for b8 and b9, b8 with a height value of 46 appears correctly in the style statement but b9 which is intended to be the numeric value obtained from the macro count80to90 actually appears as the filter expression used in count80to90.
<rect x="45" y="0" width="5" height="64" style="fill:#627; height:46; opacity:50%"></rect>
<rect x="50" y="0" width="5" height="60" style="fill:#123; height:<$count filter="[all[tiddlers]!is[system]has:field[rating3]] :filter[get[rating3]compare:integer:gteq[80]] :filter[get[rating3]compare:integer:lt[90]]
My code is horribly inefficient at the moment, I am working my way to something reasonable but the nub of this is how do I ensure that the result of a macro is evaluated and fully resolved?
Ideally I want to pass fully resolved numbers to the macro that deals with the value substitutions in the SVG code.
Thanks
I know there are plugins to add graph features to tiddlywiki but I am writing a plugin and wish to keep dependencies on other plugins to a minimum - in principle the fact that tiddlywiki parses SVG code does lend itself to some simple SVG graphs simply modifying values in an existing SVG graphic.