cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
RA899
Level III

Adding conditon to variables in graph builder in JSL

Hi 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"} )
		)
	)
);
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Adding conditon to variables in graph builder in JSL

You 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)))
	)
));

 

 

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Adding conditon to variables in graph builder in JSL

Easiest 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

-Jarmo
RA899
Level III

Re: Adding conditon to variables in graph builder in JSL

Thank 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

 

 

jthi
Super User

Re: Adding conditon to variables in graph builder in JSL

You 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)))
	)
));

 

 

-Jarmo