cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
kevinwtbolger
Level II

How to dynamically reference the y-axis of a scale box in Graph Builder using JSL

Or anywhere for that matter.

I'm writing a function that generates some specialist graphs for work. Im doing some extra drawing on the canvas and need the graph to re-adjust on the y-axis to fit everything in. I can achieve this by getting the max and min of every point I am plotting and setting those (+/- 5%) as my upper and lower limits. However, in order for the changes to take effect I need to call the axis label. I've tried index numbers. I've tried storing the name as a variable and calling the variable. None of my attempts seem to work and the documentation is not comprehensive on this topic.

Example:

Within the graph builder and send to report I have:

Dispatch({},
"The Axis Name",
ScaleBox,
{Format( "Fixed Dec", 15, 0 ), Min( llim ), Max( ulim ),
Inc( 1 ), Minor Ticks( 1 )}
),

To get this to work in a function, I currently have to hard code the name. I would like for it to update dynamically no matter what graph I am plotting.

Something to the effect of

Dispatch({},
Y-Axis,
ScaleBox,
{Format( "Fixed Dec", 15, 0 ), Min( llim ), Max( ulim ),
Inc( 1 ), Minor Ticks( 1 )}
),

Is what I am looking for.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to dynamically reference the y-axis of a scale box in Graph Builder using JSL

You pose an interesting question regarding axis identification in Graph Builder.  I have taken a look at the axis structure that Graph Builder uses, and it appears to have an organization to it, that one can use.

11614_pastedImage_0.png

The above Graph Builder chart has one Y axis and several X axes.  The structure for the graphs I tried out always used Axis 1 as the first X axis and Axis 2 and the first Y axis.  So in using the below code, even when the graph type was changed, the axis number remained the same.

Names Default to Here(1);

dt=open("$SAMPLE_DATA/semiconductor capability.jmp");

gb=Graph Builder(

                Size( 593, 526 ),

                Show Control Panel( 0 ),

                Variables( X( :PNP1 ), Y( :NPN1 ), Group X( :SITE ) ),

                Elements( Points( X, Y, Legend( 5 ) ), Smoother( X, Y, Legend( 6 ) ) )

);

report(gb)[Axis Box(1)] << min(150);

Axis Box(2) reference would change the Y axis. 

There are also Axis boxes 3,4,5 & 6, which are the other 5 X axes being displayed.

11615_pastedImage_4.png

This example has added in a second variable to the Y axis, however, the Axis Box(1) is still the first X axis, Axis Box(2) is the Y axis for the top column, "PNP4", while Axis Box(3) is the Y axis for the "NPN1" column.

Names Default to Here(1);

dt=open("$SAMPLE_DATA/semiconductor capability.jmp");

GB=Graph Builder(

                Size( 593, 526 ),

                Show Control Panel( 0 ),

                Variables( X( :PNP1 ), Y( :PNP4 ), Y( :NPN1 ), Group X( :SITE ) ));

If you rt mouse click on the Grey Expansion Triangle and select

     Edit==>Show Tree Structure

you should be able to determine the axis box structure for the graphs that you are using, and will be able to programmatically determine how to reference the correct Axis Box

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How to dynamically reference the y-axis of a scale box in Graph Builder using JSL

You pose an interesting question regarding axis identification in Graph Builder.  I have taken a look at the axis structure that Graph Builder uses, and it appears to have an organization to it, that one can use.

11614_pastedImage_0.png

The above Graph Builder chart has one Y axis and several X axes.  The structure for the graphs I tried out always used Axis 1 as the first X axis and Axis 2 and the first Y axis.  So in using the below code, even when the graph type was changed, the axis number remained the same.

Names Default to Here(1);

dt=open("$SAMPLE_DATA/semiconductor capability.jmp");

gb=Graph Builder(

                Size( 593, 526 ),

                Show Control Panel( 0 ),

                Variables( X( :PNP1 ), Y( :NPN1 ), Group X( :SITE ) ),

                Elements( Points( X, Y, Legend( 5 ) ), Smoother( X, Y, Legend( 6 ) ) )

);

report(gb)[Axis Box(1)] << min(150);

Axis Box(2) reference would change the Y axis. 

There are also Axis boxes 3,4,5 & 6, which are the other 5 X axes being displayed.

11615_pastedImage_4.png

This example has added in a second variable to the Y axis, however, the Axis Box(1) is still the first X axis, Axis Box(2) is the Y axis for the top column, "PNP4", while Axis Box(3) is the Y axis for the "NPN1" column.

Names Default to Here(1);

dt=open("$SAMPLE_DATA/semiconductor capability.jmp");

GB=Graph Builder(

                Size( 593, 526 ),

                Show Control Panel( 0 ),

                Variables( X( :PNP1 ), Y( :PNP4 ), Y( :NPN1 ), Group X( :SITE ) ));

If you rt mouse click on the Grey Expansion Triangle and select

     Edit==>Show Tree Structure

you should be able to determine the axis box structure for the graphs that you are using, and will be able to programmatically determine how to reference the correct Axis Box

Jim
kevinwtbolger
Level II

Re: How to dynamically reference the y-axis of a scale box in Graph Builder using JSL

This perfectly solved my problem. Thanks Jim. My function is still a work in progress re: making it generic enough to share but once I figure it out but I will post here on the JMP community once I have made it generic enough.

For anyone wondering, I believe my issue is I was trying to reference the report within the report, before it was fully generated (though I may be wrong there).

Re: How to dynamically reference the y-axis of a scale box in Graph Builder using JSL

As a follow-on to Jim's example, you can use XPath() to obtain a list of all the AxisBoxes in the report.  Then, you can loop through the list making the desired changes as appropriate.  The following demonstrates XPath() and then simply selects each axis in a For loop.

 

/* Obtain a list of al the AxisBoxes in the report */

gbAxis = Report( gb ) << XPath( "//AxisBox" );

/* Loop through each to see which axis each references */

For( i = 1, i <= N Items( gbAxis ), i++,

    gbAxis[i] << Select;

       Wait( 1 );

);


I hope this helps!

Wendy

Wendy