Hi, I have been trying for a while to write a code in JSL where depending on the value of certain variable, the graph obtained from graph builder changes.
My particular example right now is pretty simple, I have a check box and depending on the user selection (checked/unchecked) I want to add or remove groups into the graph using the local filter. Here is a very simple example
dt = Open( "$SAMPLE_DATA/Analgesics.jmp" );
// Open Analgesics
cb = 1; // Predefined value<BR /><BR />// Check box to Remove group A from the graph
usw = New Window("Ignore A?", << Modal,
//Check Box defaulted to checked ignore
checkIgnore = check box({"Ignore A?"},
<< Set(1,1),
cb = checkIgnore << Get())
);
// Answer to Cancel or close buttons
If( usw["button"] == -1, throw("User cancelled") );
show(cb); // I can see how the value of cb changes between 0 and 1
nw = New Window( "Example Report",
// Box plot with dots
dot_box_plot = dt << Graph Builder(
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Title( 0 ),
Variables( X(:drug ), Y( :pain ), Color(:drug ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 2 ) ), Box Plot( X, Y, Legend( 3 ) ) ),
Elements( Position( 2, 1 ), Points( X, Y, Legend( 2 ) ), Box Plot( X, Y, Legend( 3 ) ) ),
SendToReport( Dispatch( {}, "X title", TextEditBox, {Set Text( "" )} ) ),
/* This is the part that I'd like to make interactive
to keep or remove A-group from the plot depending on
user selection */
if(cb == 1,
Local Data Filter(
Close Outline( 1 ),
Add Filter( columns( :drug ),
Where( :Drug != "A" )
)
)
)
)
);As you can see, there should be something wrong in my part with the if statement because nothing changes, the plot keeps all groups. And of course, when I remove only the IF() part, my plot ignores the group A.
I would be very thankful for any suggestions.