- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Handling Conditional Display of Y-Axis Variables in JSL for Graph Building
When using `graph built`, how can I describe the requirement in JSL that certain Y-axis variables, which may not always appear, should be displayed if they have values and not displayed if they have no values? The following two methods have not been effective.
1.
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :sex ), try(Y( :bbb )), Y( :height ), Y( :weight ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 13 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 14 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 15 ) ) )
);
2.
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( :bbb ), Y( :height ), Y( :weight ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 13 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 14 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 15 ) ) )
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Handling Conditional Display of Y-Axis Variables in JSL for Graph Building
You can build the expression or add variable later
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(534, 450),
Show Control Panel(0),
Variables(X(:sex), Y(:height), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(13))),
Elements(Position(1, 2), Points(X, Y, Legend(14)))
);
dt << new column("A", Numeric, Continuous, Formula(Row()));
extra_cols = {"height", "A"};
For Each({extra_col}, extra_cols,
Eval(EvalExpr(
gb << Add Variable({Expr(NameExpr(AsColumn(dt, extra_col))), Role("Y")});
));
);
Depending on what you are trying to do, there can be quite a few things to take into account (order, type of plots, legend, ...)
If I remember correctly this might have something related to this topic Scripters Club Recording: JSL in Graph Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Handling Conditional Display of Y-Axis Variables in JSL for Graph Building
Hi @BabyDoragon, is bbb a column that either exists or not and this is what we need to check, or bbb is always there but some values(rows) are missing ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Handling Conditional Display of Y-Axis Variables in JSL for Graph Building
The default value of bbb is {}, and sometimes it may be stored as a variable, for example in the following two cases.
1.
dt = Open("$SAMPLE_DATA/Big Class.jmp");
bbb={};
bbb="age";
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( as column(bbb)), Y( :height ), Y( :weight ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 13 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 14 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 15 ) ) )
);
2.
dt = Open("$SAMPLE_DATA/Big Class.jmp");
bbb={};
//bbb="age";
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( as column(bbb)), Y( :height ), Y( :weight ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 13 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 14 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 15 ) ) )
);
I hope to enable the graph to automatically include or exclude this item based on whether there are any variables currently in bbb.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Handling Conditional Display of Y-Axis Variables in JSL for Graph Building
You can build the expression or add variable later
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(534, 450),
Show Control Panel(0),
Variables(X(:sex), Y(:height), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(13))),
Elements(Position(1, 2), Points(X, Y, Legend(14)))
);
dt << new column("A", Numeric, Continuous, Formula(Row()));
extra_cols = {"height", "A"};
For Each({extra_col}, extra_cols,
Eval(EvalExpr(
gb << Add Variable({Expr(NameExpr(AsColumn(dt, extra_col))), Role("Y")});
));
);
Depending on what you are trying to do, there can be quite a few things to take into account (order, type of plots, legend, ...)
If I remember correctly this might have something related to this topic Scripters Club Recording: JSL in Graph Builder