Adding conditon to variables in graph builder in JSLHi all,
I'm trying to modify the graph builder code which has certain variables. I would like to add conditional statements to include or exclude those certain variables. I tried using if statements, but it doesn't seem to work properly. I would appreciate any suggestions in the matter.
Example code:
I want to take an input from the user (already done with this part), to evaluate whether the user wants the results against the test temp (for example). I do have other variables to plot against, but I provided test temp to simplify the example.
// x will be taken as an input
Graph Builder(
Size( 1257, 829 ),
Level Spacing Color( "Black" ),
Variables( Y( :TX_EVM ), Y( :TX_EVM ), If( Equal( X, 1 ), Group X( :Test_Temp ) ) ),
Elements( Box Plot( Y, Legend( 19 ) ) ),
Local Data Filter(
Add Filter(
columns( :Test_Temp ),
Where( :Test_Temp == {"test temp1 ", "test temp2", "test temp3"} )
)
)
);
Advanced Statistical ModelingAutomation and ScriptingBasic Data Analysis and ModelingWindowsRe: Adding conditon to variables in graph builder in JSLEasiest option is to most likely remove the variable after graph build creation
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 492),
Show Control Panel(0),
Variables(X(:weight), Y(:height), Group X(:sex)),
Elements(Points(X, Y, Legend(5)))
);
// gb << Get Variables; // depending on your graph calculating which index to remova can be a good idea
gb << Remove Variable(3);
wait(0);
You could also build the Variables() part of Graph Builder() message using expressions
Re: Adding conditon to variables in graph builder in JSLYou might have to wrap your TestList[i3] with something. Below are some options
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
mycol = "weight";
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:age), X(:sex), Y(mycol)), // won't work
Elements(Position(1, 1), Points(X, Y, Legend(6))),
Elements(Position(2, 1), Points(X, Y, Legend(7)))
);
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:age), X(:sex), Y(Eval(mycol))), // might work
Elements(Position(1, 1), Points(X, Y, Legend(6))),
Elements(Position(2, 1), Points(X, Y, Legend(7)))
);
Eval(EvalExpr(
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:age), X(:sex), Y(Expr(NameExpr(AsColumn(mycol))))), // works
Elements(Position(1, 1), Points(X, Y, Legend(6))),
Elements(Position(2, 1), Points(X, Y, Legend(7)))
)
));
Re: Adding conditon to variables in graph builder in JSLThank you Jarmo for your help. Your code works perfectly fine, but when implement the same technique to my original code it isn't working. My code actually does create multiple graph builders and appends them. I tried to remove variables after each graph builder, but it doesn't seem to make any difference.
A simplified version of the code I have is this:
gb = {}; // initiate list
// loop through the test list
index = N Items( gb );//
gb[index + 1]= New Window( "Capability", hlb = H List Box() );
hlb << append(//
Graph Builder(
Size( 1800, 700),//
Variables(
X( :Temp, Position( 1 ) ),
X( :Location, Position( 1 ) ),
Y( TestList[i3] ), // this is
),
Elements( Histogram( X( 1 ), X( 2 ), X( 3 ), Y, Legend( 46 ), Means and Std Devs( 1 )),Smoother( X( 1 ), X( 2 ), X( 3 ), X( 4 ), Y, Legend( 49 ) ) ,Caption Box(
X( 1 ),
X( 2 ),
X( 3 ),
Y,
Legend( 51 ),
Summary Statistic( "Mean" ),
) ),
Local Data Filter(
.
.
.
.
.
.
.
),
SendToReport(
.
.
.
.
.
.
.
)
);
);
//end loop<BR />