Subscribe Bookmark RSS Feed

How do I substitute from elements of a list into a graph builder expression

myoungers

Community Trekker

Joined:

Mar 20, 2012

I am writing a script that will generate a number a charts from the graph builder platform.  I would like the script to be dynamic for the data table columns used in the graph builder analysis and also dynamic for the scalebox options.  I currently envision two lists (can also be in a matrix or even a data table???).  The first list would contain all of the variables in the graph builder expression.  The second list may even be a list of lists so it can support multiple charts.  It would contain the values to be subsisted (scale min, scale max, parameter/column name from the data table).  I am attaching an example of the code I'm trying to use.  Any help that anyone can offer would be greatly appreciated.

Thanks,

Matt

subM = List( parI, parE, minI, maxI );

testM = List( {"Internal Parameter A", "External Parameter B", 100, 200} );

For( i = 1, i < N Items( testM ) + 1, i++,

    gb = Expr(

        Graph Builder(

            Show Control Panel( 0 ),

            Variables( X( :System ), X( :Run, Position( 1 ) ), X( :Position, Position( 1 ) ), Y( parI, Side( "Right" ) ), Y( parE, Position( 1 ) ) ),

            Elements(

                Points( X( 1 ), X( 2 ), X( 3 ), Y( 2 ), Legend( 7 ), Jitter( 1 ) ),

                Points( X( 1 ), X( 2 ), X( 3 ), Y( 2 ), Legend( 9 ), Jitter( 1 ) ),

                Points( X( 1 ), X( 2 ), X( 3 ), Y( 1 ), Legend( 8 ), Jitter( 1 ) )

            ),

            SendToReport(

                Dispatch( {}, "System", ScaleBox, {Show Major Ticks( 1 ), Show Minor Ticks( 0 ), Rotated Labels( "Automatic" )} ),

                Dispatch( {}, "X1", ScaleBox, {Min( 90 ), Max( 190 ), Inc( 10 ), Minor Ticks( 1 )} ),

                Dispatch( {}, "X2", ScaleBox, {Min( minI ), Max( maxI ), Inc( 10 ), Minor Ticks( 1 )} ),

                Dispatch( {}, "X3", FrameBox, {Marker Size( 3 )} )

            )

        )

    );

   

    For( j = 1, j < N Items( testM ) + 1, j++,

        Substitute( gb, subM, testM )

    );

    gb;

    Wait( 0 );

);

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

I generate dynamic graphs using graph builder using the following approach:

  • I create a string (e.g. gb_expr) that contains the necessary graph builder commands.

  • I execute the string using eval(parse(gb_expr))

Here's an example that uses evalinsert as a convenient way to insert variables into the graph builder string.

gb_expr = evalinsert("\[

trend_chart_cc = Graph Builder(

    Show Control Panel( 0 ),

    Variables( X( :^xaxis_col^  ), Y( :^yaxis_rbox_value^  ), Overlay( :^plot_cbox_value^  ) ),

    Elements(

        Points( X, Y, Legend( 2 ) ),

        Line( X, Y, Legend( 4 ), Row order( 0 ), Summary Statistic( "Mean" ) )

    ),

    SendToReport(

        Dispatch(

            {},

            "Graph Builder",

            OutlineBox,

            {Set Title( "Case Count" )}

        ),

        Dispatch( {}, ^xaxis_col^, ScaleBox, {Rotated Labels( "Automatic" )} ),

        ^marker_text^

        Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 3 )} ),

        ^legend_text^,

        Dispatch(

            {},

            "graph title",

            TextEditBox,

            {Set Text( "^snap_name^" )}

        ),

    )

);

]\");

2 REPLIES
Solution

I generate dynamic graphs using graph builder using the following approach:

  • I create a string (e.g. gb_expr) that contains the necessary graph builder commands.

  • I execute the string using eval(parse(gb_expr))

Here's an example that uses evalinsert as a convenient way to insert variables into the graph builder string.

gb_expr = evalinsert("\[

trend_chart_cc = Graph Builder(

    Show Control Panel( 0 ),

    Variables( X( :^xaxis_col^  ), Y( :^yaxis_rbox_value^  ), Overlay( :^plot_cbox_value^  ) ),

    Elements(

        Points( X, Y, Legend( 2 ) ),

        Line( X, Y, Legend( 4 ), Row order( 0 ), Summary Statistic( "Mean" ) )

    ),

    SendToReport(

        Dispatch(

            {},

            "Graph Builder",

            OutlineBox,

            {Set Title( "Case Count" )}

        ),

        Dispatch( {}, ^xaxis_col^, ScaleBox, {Rotated Labels( "Automatic" )} ),

        ^marker_text^

        Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 3 )} ),

        ^legend_text^,

        Dispatch(

            {},

            "graph title",

            TextEditBox,

            {Set Text( "^snap_name^" )}

        ),

    )

);

]\");

myoungers

Community Trekker

Joined:

Mar 20, 2012

Thanks for the help!