JSL - Check box to select variable to then plot in graph builderHi everyone,
I am trying to make a script which would work this way:
1. Opens a new window showing "Select the parameters you want to plot" with a list of parameters with check box for each, and the operator would chose which ones he wants to plot by ticking them.
2. Then for the ones that are ticked, open a graph builder with the corresponding variables.
I am currently able to make the first step (new window and list with check boxes), and I know how to script to create a graph, but I miss the link between them ... I was initially thinking of calling each check box indivudally and then do a succession of "if" like "if cb1 is ticked, then do the graph, if not, then if cb2 is ticked etc ...". I tried the following script to train but it always displays "Failed" in the end no matter if I ticked the box, so it does not really check the box:
Names Default To Here( 1 );
New Window( "Choose the parameters to be plotted",
cb1 = Check Box ("Parameter 1",0),
cb2 = Check Box ("Parameter 2",0)
);
wait(5);
If (cb1 == 1,
Graph Builder(
Variables(
X( :Name( "Process duration" ) ),
Y( :Name( "Parameter 1" ) ) ) ),
New Window( "Failed"));Do you have any idea how to do that?
@martindemel
Re: JSL - Check box to select variable to then plot in graph builderSorry for that. Meanwhile I did kudos Mark as well.Re: JSL - Check box to select variable to then plot in graph builderkudos goes to Mark
Re: JSL - Check box to select variable to then plot in graph builderThanks Martin, for this helpful script.Re: JSL - Check box to select variable to then plot in graph builderI just tested this solution and it worked perfectly, thank you !!Re: JSL - Check box to select variable to then plot in graph builderExample:
Names Default to Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dialog = Column Dialog(
col = Col List( "X, Factor", Min Col( 1 ), Max Col( 1 ) )
);
If( dialog["Button"] == -1, Throw( "User cancelled" ) );
Remove From( dialog );
Eval List( dialog );
x = col[1];
dt << Graph Builder(
Size( 534, 454 ),
Show Control Panel( 0 ),
Variables( X( x ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 3 ) ) )
);
Re: JSL - Check box to select variable to then plot in graph builderI'm not sure to understand
I see the point of using the column dialog to ask the operator to select the column but still I don't know how to link that with automatic graph building after?Re: JSL - Check box to select variable to then plot in graph builderok, makes sense. Even then you could use the column dialog, though you then need to slightly adjust your script to have the correct variable name used. The nice thing is you can use a self defined variable name you want to use in your script further on and remuve the dependency on the table variable names. You still can do an if_else structure, but instead of :age you can use your own name which makes the script more general and usually then also more robust.Re: JSL - Check box to select variable to then plot in graph builderThe Choose() method that I used is appropriate for Radio Box, but not as useful for the Check Box input case - it only allows one of the statements to be executed.
Try something like:
If(cb<<GET></GET>
Note that CheckBox<
http://www.jmp.com/support/help/en/15.1/#page/jmp/display-functions.shtml#ww2548850
Re: JSL - Check box to select variable to then plot in graph builderHi Martin,
Actually I didn't mentionned the full picture: I already have a script which build all graphes one by one, save them into the journal and then close the graph builder. So at the end of this script, I have a journal with all my graphs.
Now I would like to add a first step to this graph which is the variable selection. So I need that the operator selects what he wants, and then for all the selected variable, the second scrip graph builder -> Journal should applies.
Does that make sense?
Re: JSL - Check box to select variable to then plot in graph builderMay not exactly what you need, but if you want to create a Graph for each of the selected variables you might want to consider a Column Dialog to let the operator select the variables he wants to plot in X and Y roles and then plot this for each selected variable:
https://www.jmp.com/support/help/en/15.1/?os=win&source=application#page/jmp/construct-a-column-dialog.shtml#
Names Default to Here(1);
dt = Open("$SAMPLE_DATA/Tablet Production.jmp", Invisible);
cdb = Column Dialog("Add continuous variables you want to plot against Dissolution" ,
colxx = ColList( "X", Min Col( 1 ), Modeling Type( "Continuous" ) ),
);
show(cdb);
Eval List(cdb[1::N Items(cdb)-1]);
Graph Builder(
Size( 526, 454 ),
Show Control Panel( 0 ),
Variables( X( colxx[1] ), Y( :Dissolution )),
Elements( Points( X, Y, Legend( 3 ) ), Line Of Fit( X, Y, Legend( 5 ) ) ),
Column Switcher( colxx[1], colxx )
);
Re: JSL - Check box to select variable to then plot in graph builderI tried to change the radio box into check box in your example, but again it is only doing one single graph even if multiple boxes are selected (and actually it is not working for Height & I have no idea why)... I think I still miss something in that script:
Names Default To Here( 1 );
dt=Open("$SAMPLE_DATA/Big Class.jmp");
rc = New Window("Choose the parameters to be plotted",
cb = Check box ({"weight", "height", "sex"}),
Button Box("Ok",
Choose(cb<<GET></GET>
Re: JSL - Check box to select variable to then plot in graph builderIn that case you can keep the Check Box() displays that you were originally using - I wasn't clear from your example how the inputs were going to be used if both items (or neither of them) were checked. RadioBox is a nice control if you want one and only one response, but you can use either of the input methods with any set of controls, including TextEditBox() for string input or NumberEditBox() for numeric input.
Re: JSL - Check box to select variable to then plot in graph builderThat seems promising thanks a lot !! However in what you suggested, it's either one box or the other but not both, whereas I would like to have as many boxes ticked as required ... What should I change in your scripts?
Re: JSL - Check box to select variable to then plot in graph builderWhen prompting for input in a dialog, here are two common ways to do things:
1. Use a modal dialog to pause the execution of the script while waiting for input:
Names Default To Here( 1 );
dt=Open("$SAMPLE_DATA/Big Class.jmp");
// Prompt for the input
rc = New Window("Choose the parameters to be plotted",
<<MODAL></MODAL>// Launch report if Ok was pressed
if (rc["Button"] == 1,
// Ok pressed
Choose (rc["rb"],
Graph Builder(Variables(X(:age), Y(:weight))),
Graph Builder(Variables(X(:age), Y(:height)))
);
,
// Cancel
"Cancel"
)
In your script, variable "cb1" is a DisplayBox. In this example, the <
2. Do the "action" part of the dialog as part of a button script:
Names Default To Here( 1 );
dt=Open("$SAMPLE_DATA/Big Class.jmp");
// Prompt for the input and create graph
rc = New Window("Choose the parameters to be plotted",
rb = Radio Box({"weight", "height"}),
Button Box("Ok",
Choose(rb<<GET></GET>
A modal dialog will block all other input to other windows, while the second approach would allow you to continue using other windows in JMP at the same time.
Hope that helps!
Re: JSL - Check box to select variable to then plot in graph builderSimple and effective. Nice!