Graph builder element loop functionHow can i use loop function for multiple position definition?
If separate like below it work:
Eval(
Substitute(
Expr(
gb = cdt << Graph Builder(
Size( 600, 800 ),
Show Control Panel( 0 ),
vvv,
Elements(Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) )
),
Elements(
Position( 2, 1 ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend( 6 )
),
Elements(
Position( 2, 2 ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend( 7 )
),
Elements(
Position( 2, 3 ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend( 8 )
)
)
),
Expr( vvv ),
Name Expr( var expr )
)
);But if using loop like this it's only have bar, what's missing in this code?
Eval(
Substitute(
Expr(
gb = cdt << Graph Builder(
Size( 600, 800 ),
Show Control Panel( 0 ),
vvv,
Elements(Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) )
),
For( j = 1, j <= n_mydatecol, j++,
Elements(
Position( 2, j ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend(eval( 5 + j ))
),
),
)
),
Expr( vvv ),
Name Expr( var expr )
)
);
Automation and ScriptingWindowsRe: Graph builder element loop functionYou could build the elements expressions separately and then evaluate it inside graph builder expression. Or in some cases it might be easier if you use << Add Element
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(Variables(X(:height), Y(:weight)), Elements(Points(X, Y), Smoother(X, Y)));
Wait(0.5);
gb << Add Element(1, 1, {Type("Line Of Fit"), X, Y, Degree("Quadratic")});Re: Graph builder element loop functionmy chart want to be like this, do I need to define the position?

Re: Graph builder element loop functionAdd element does allow you setting X and Y position. Did you try if it would work for your use case?
Translation body successfully posted
Re: Graph builder element loop functionI will have to create example data (or find appropriate one) and re-create the graph so it will take some time
Re: Graph builder element loop functionI can see all the images have changed to something totally different they were earlier... I'm not sure how well the scripts provided to correspond to those new images. Which columns would have to be added dynamically and where?
Graph builder script for this

looks something like this
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:height), X(:sex), Y(:weight)),
Elements(
Position(1, 1),
Points(X, Y, Legend(5)),
Smoother(X, Y, Legend(6)),
Line Of Fit(X, Y, Legend(8))
),
Elements(
Position(2, 1),
Points(X, Y, Legend(18)),
Bar(X, Y, Legend(19), Bar Style("Float"), Label("Label by Value"))
)
);
If you have a plot like this and you wish to add float bar chart to it to the right side with points

You can use add element
gb << Add Element(2, 1, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
View more...
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:height), X(:sex), Y(:weight)),
Elements(
Position(1, 1),
Points(X, Y, Legend(5)),
Smoother(X, Y, Legend(6)),
Line Of Fit(X, Y, Legend(8))
),
Elements(
Position(2, 1),
Points(X, Y, Legend(18))
)
);
gb << Add Element(2, 1, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
Re: Graph builder element loop functionHi Jarmo,
Thanks for the helping, it can work went the y axis only have one, but what I want is if their have multiple y axis, can i still using loop function to have the element with box plot and bar? I had tried like the first one, but it only showed box plot without bars.
Re: Graph builder element loop functionI'm not sure what you are plotting, but it might (or might not) work. Here I'm using Add Element to add bar chart to X axis 2 and Y axis 1 and 2
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:height), X(:sex), Y(:name), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(20))),
Elements(
Position(1, 2),
Points(X, Y, Legend(5)),
Smoother(X, Y, Legend(6)),
Line Of Fit(X, Y, Legend(8))
),
Elements(Position(2, 1), Points(X, Y, Legend(19))),
Elements(Position(2, 2), Points(X, Y, Legend(18)))
);
gb << Add Element(2, 1, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
gb << Add Element(2, 2, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});

Re: Graph builder element loop functionIt works, and I try like this.
Thanks a lot
Eval(
Substitute(
Expr(
gb = cdt << Graph Builder(
Size( 600, 800 ),
Show Control Panel( 0 ),
vvv,
Elements(Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) )
),
);
For( i = 1 , i <= n_mymetric , i++,
gb << Add Element(2, i, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
),
),
Expr( vvv ),
Name Expr( var expr )
)
);