The script below is for a table that has a formula column with a script to make graphs from rows.
When a row is selected, the contents of several of the columns for the selected row are made into a subset table, which is transposed so it can be graphed with an overlay plot. The original script that is in the formula column starts out looking a lot different, and its inclucded below the table script.
(copy the table script into a script window and run the script)
New Table( "result table",
Add Rows( 5 ),
New Column( "Analysis",
Character,
Nominal,
Set Values( {"ANOVA", "Apple", "Bannana", "Orange", "Peach"} )
),
New Column( "Result 1",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() )
),
New Column( "Result 2",
Numeric,
Continuous,
Format( "", 9 ),
Formula( Random Uniform() )
),
New Column( "Result 3",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() )
),
New Column( "Result 4",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() ),
Set Selected
),
New Column( "Result 5",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() )
),
New Column( "Result 6",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() )
),
New Column( "Result 7",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() )
),
New Column( "Result 8",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() )
),
New Column( "Result 9",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula( Random Uniform() )
),
New Column( "Column with Formula to make graphs",
Numeric,
Continuous,
Format( "Best", 12 ),
Formula(
If( Selected( Row State() ),
Eval(
Parse(
Names Default To Here( 1 );
Clear Symbols( 1 );
dt0 = Current Data Table();
rn = dt0 << get selected rows;
tn = dt0:Analysis[rn];
dt1 = Data Table( "result table" ) <<
Subset(
Output Table( tn[1] ),
selected columns( 0 ),
Selected Rows( 0 ),
Rows( rn )
);
dt2 = dt1 << columns(
:Result 1,
:Result 2,
:Result 3,
:Result 4,
:Result 5,
:Result 6,
:Result 7,
:Result 8,
:Result 9
)`;
graph1 = Expr(
dt2 << Overlay Plot(
Y( Column( 2 ) ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
)
);
journgraph1 = Eval( graph1 ) << Get Journal;
New Window( "Report Window For " || tn[1],
Text Box( "Graph of " || tn[1] ),
Journal Box( journgraph1 )
);
Close( dt1, no save );
Close( dt2, no save );
)
)
)
)
),
Set Row States( [0, 0, 0, 0, 1] )
)
This is the script to paste into the formula column
(1);
();
( Selected( Row State() )
(
(
(1);
(1);
=current data table();
=dt0<<get selected rows;
=dt0:Analysis[rn];
=Data Table( "result table" ) << Subset(
1] ),
0),
0 ),
//,invisible
;
=dt1 << Transpose(
:Result 1,
:Result 2,
:Result 3,
:Result 4,
:Result 5,
:Result 6,
:Result 7,
:Result 8,
:Result 9,
:Column 11
,
:Analysis[rn] ),//this doesn't get translated in the formula
1]||" for graph" )//,invisible
;
=expr(dt2<<Overlay Plot( Y( column(2) ), Separate Axes( 1 ), Connect Thru Missing( 1 ) ));
=eval(graph1)<<Get Journal;
("Report Window For "||tn[1], Text box("Graph of "||tn[1]), Journal Box (journgraph1));
(dt1, no save);
(dt2, no save);
//end of parse
//end of eval
;//end of if
JMP Systems Engineer, Health and Life Sciences (Pharma)