Hello JSL Scripters,
I'm working on a script, where I am adding my own "legend" to a graph. See screenshot below.

I've added the lines and text by right clicking in the graph Customize...> and then adding a Script to the graph. The following JSL generates the "legend" as shown above.
Pen Color( "Red" );
Pen Size( 2 );
Line Style( "Solid" );
Line( [20, 100], [65, 65] );
Text( {120, 64}, "Weight" );
Pen Color( "Blue" );
Pen Size( 2 );
Line( [20, 100], [60, 60] );
Text( {120, 59}, "Height" );
But, what I'm really after is how to make the positions of the legend lines and text relative to, e.g. 90% the maximum value in the column :"Weight diff [g]"n. Data table is attached as well with script (non working script is commented out). I thought I could do it with something like an Eval(Substitute(Expr(...), Expr(__pos__), pos) type of JSL, but I keep getting the "Invalid Matrix Token" error. With something like the following:
Names Default To Here( 1 );
pos = Col Max( :"Weight diff[g]"n );
Eval(
Substitute(
Expr(
Graph Builder(
Size( 510, 510 ),
Show Legend( 0 ),
Graph Spacing( 4 ),
Variables(
X( :"MeasTime [s]"n ),
Y( :"Weight diff [g]"n ),
Y( :"Height diff [mm]"n, Position( 1 ), Side( "Right" ) )
),
Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) ),
SendToReport(
Dispatch( {}, "MeasTime [s]", ScaleBox, {Inc( 100 )} ),
Dispatch( {}, "Graph Builder", FrameBox,
{Add Graphics Script(
5,
Description( "" ),
Pen Color( "Red" );
Pen Size( 2 );
Line Style( "Solid" );
Line( [20, 100], [__pos__, __pos__] );
Text( {120, 64}, "Weight" );
Pen Color( "Blue" );
Pen Size( 2 );
Line( [20, 100], [60, 60] );
Text( {120, 59}, "Height" );
)}
)
)
)
),
Expr( __pos__ ), Eval( Round( 0.9 * pos, 0 ) )
)
);
I've even tried wrapping the y-coordinates of the Line() in "{ }", like: Line( [20, 100],[{_pos__,__pos__}]), and I still get the same error. I'd prefer to use a variable like "pos", that I get from a column rather than have it as an absolute value because the column values can change and I need the graph objects like the line and text to be able to move relative to what's being graphed.
Any suggestions on how to get around this error and/or what I'm missing -- this approach should work, but I'm just not catching why.
Thanks!,
DS