cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Lino
Level III

JSL to Set Graph Y axis Max Value based on Cell Value

I am plotting graph and add refence line. I would like the reference line and Y max axis value can be seen on the graph. I am trying to set the Y axis max value based on the max cell value. 

 I do not see the Y max appear in the graph.

Below is my script. Can anyone advise what wrong with the script?

dt= Current Data Table();

MX = Max(:Weight);
If(
	MX < 80, 
	    MX = 90; 
	    MX = MX + 10
);

dt << Overlay Plot(
	X( :WW ),
	Y( :Weight ),
	Y Axis[1] << {{Max( MX ), Minor Ticks( 1 ),
	Add Ref Line( 80, "Solid", "Red", "", 1 )}},
	Separate Axes( 1 ),
	Connect Thru Missing( 1 ),
	
		Dispatch(
			{},
			"106",
			ScaleBox,
			{Max( MX ), Minor Ticks( 1 ),
			Add Ref Line( 80, "Solid", "Red", "", 1 )}
		),
		Dispatch(
			{},
			"101",
			ScaleBox,
			{Min(0), Max( 11 ), Inc( 1 ), Minor Ticks( 1 )}
		)
	
);
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL to Set Graph Y axis Max Value based on Cell Value

The Overlay plot has been depreciated.  One should be using the Graph Builder for this type of graphic.

overlay.PNG

Here is the script for the graph above

dt= Current Data Table();

MX = col Max(:Weight);
If(
	MX < 80, 
	    MX = 90,
	    MX = MX + 10
);

gb = dt <<Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :WW ), Y( :Weight ) ),
	Elements( Line( X, Y, Legend( 16 ) ), Points( X, Y, Legend( 17 ) ) )
);
report(gb)[AxisBox(2)] << max(MX) << add ref line( 80, "Solid", "Red", "", 1 );
report(gb)[AxisBox(1)] << min(0) << max(11) << incr(1);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: JSL to Set Graph Y axis Max Value based on Cell Value

The Overlay plot has been depreciated.  One should be using the Graph Builder for this type of graphic.

overlay.PNG

Here is the script for the graph above

dt= Current Data Table();

MX = col Max(:Weight);
If(
	MX < 80, 
	    MX = 90,
	    MX = MX + 10
);

gb = dt <<Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :WW ), Y( :Weight ) ),
	Elements( Line( X, Y, Legend( 16 ) ), Points( X, Y, Legend( 17 ) ) )
);
report(gb)[AxisBox(2)] << max(MX) << add ref line( 80, "Solid", "Red", "", 1 );
report(gb)[AxisBox(1)] << min(0) << max(11) << incr(1);
Jim
Lino
Level III

Re: JSL to Set Graph Y axis Max Value based on Cell Value

Thanks Jim.