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
BL1
BL1
Level I

Graph builder won't autoscale

Hello,

I am launching a graph builder and data filter from a dashboard. The graph is date on the x axis and count on the y axis. When I filter the date, the data outside of the date range disappears from the graph, but the graph does not autoscale the x axis to match the dates within the filtered range (instead, the x axis date range is the same as before filtering the date range).

I know that I can open the data table, then go to column properties, then axis, then removed the min and max, and then it works, but I need the autoscaling to happen automatically. 

The graph builder script looks like this:

SPC = Open("C:\blahblahblah.csv",invisible);

column(SPC,"blah")<<data type(Numeric)<<Modeling Type(Continuous)<<Format(Best,1);
column(SPC,"blah2")<<data type(Numeric)<<Modeling Type(Continuous)<<Format(Best,1);

plot_box=vlistbox(

SPC << Graph Builder(
Size( 1372, 867 ),
Show Control Panel( 0 ),
Automatic Recalc( 1 ),
Auto Stretching( 0 ),
Variables( X( :Date time ran ), Y( :blah ), Y( :blah2 ), Overlay( :blah3 ) ),

Elements(
Position( 1, 1 ),
Points( X, Y, Legend( 1 ), Jitter( 1 ) ),
),
Elements(
Position( 1, 2 ),
Points( X, Y, Legend( 4 ), Jitter( 1 ) ),
),
SendToReport(
Dispatch(
{},
"Date time ran",
ScaleBox,
{Interval( "Day" ),
Inc( 3 ), Minor Ticks( 1 ),

(then a bunch of reference lines)

...

 

Could someone please advise me?

Thank you.

4 REPLIES 4
gzmorgan0
Super User (Alumni)

Re: Graph builder won't autoscale

I see the same behavior on GraphBuilder.  I noticed the option Lock Scales on GraphBuilder. However, If I specify Lock Scales(0) when GraphBuilder is created the x-axis still does not rescale.  If after the GraphBuilder is created you turn on Lock Scales and turn it off, the axis will scale, but it will not have any custom axis formatting. The example below uses yyyyQq. The script below will run in JMP 12, 13 and 14.

 

If you have JMP 14, remove the /* in line 52 and run the script.  In JMP 14, there is Data Filter Handler, a script that runs when the filter is changed. So if you have a special axis format you can specify it in the handler.   

 

Lock Scales(0) in the GraphBuilder calling function doesn't seem to work as described. But enabling and disabling seems to work.

Names Default to Here(1);

dt = Open("$sample_data/Australian Tourism.jmp");

gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Lock Scales(0),
	Variables(
		X( :Date ),
		Y( :Name( "Revenue ($'000)" ) ),
		Y( :Name( "Bed occupancy rate (%)" ) ),
		Y( :Name( "Average length of stay (days)" ) )
	),
	Elements(
		Position( 1, 1 ),
		Points( X, Y, Legend( 4 ) ),
		Smoother( X, Y, Legend( 3 ) )
	),
	Elements(
		Position( 1, 2 ),
		Points( X, Y, Legend( 1 ) ),
		Smoother( X, Y, Legend( 2 ) )
	),
	Elements(
		Position( 1, 3 ),
		Points( X, Y, Legend( 6 ) ),
		Smoother( X, Y, Legend( 5 ) )
	),
	SendToReport(
		Dispatch(
			{},
			"Date",
			ScaleBox,
			{Format( "yyyyQq", 6 ), Min( 2953282344.82759 ), Max( 3408220800 ),
			Interval( "Year" ), Inc( 1 ), Minor Ticks( 0 )}
		),
		Dispatch( {}, "graph title", TextEditBox, {Set Text( "Tourism Trends" )} )
	)
);

filter = gb <<  Local Data Filter(
		Add Filter(
			columns( :Year )
		)
	);
	
  gb << Lock Scales(1);
  wait(0);
  gb << Lock Scales(0);
	
/*
f = function({a}, 
     print(a);
	  gb << Lock Scales(1);
	  wait(0);
	  gb << Lock Scales(0);
	  gb << Dispatch(
			{},
			"Date",
			ScaleBox,
			{Format( "yyyyQq", 6 ),
			Interval( "Year" ), Inc( 1 ), Minor Ticks( 0 )}
		); 
);

rs = filter << Make Filter Change Handler( f );

 

 

 

BL1
BL1
Level I

Re: Graph builder won't autoscale

Thank you for your reply.

Strangely, when I perform lock scales and unlock scales, the dates are not scaled for the date ranges outside of my reference lines (if I try to select a date range that does not include any reference lines, the date (x-axis) does not scale, but the data outside of that range is excluded; if I select a date range which is within the grouping of reference lines, the dates (x-axis) will scale). I have JMP 11; perhaps this is a bug in this version? Or perhaps I should not have coded in my reference lines? I don't know how to plot reference lines along the x-axis though...

gzmorgan0
Super User (Alumni)

Re: Graph builder won't autoscale

I see similar rescaling behavior in JMP 14, using reference lines on the x-axis. In other words,  it seems JMP tries to maintain the script or reference lines.  Here is an example of specifying reference lines via JSL.

Dispatch(
	{},
	"Date",
	ScaleBox,
	{Format( "yyyyQq", 6 ), Min( 3092688000 ), Max( 3284668800 ),
	Interval( "Year" ), Inc( 1 ), Minor Ticks( 0 ),
	Add Ref Line( Informat("06Mar2003", "ddmonyyyy"), "Solid", "Gray", "", 1 ),
	Add Ref Line( Informat("16Jul2006", "ddmonyyyy"), "Solid", "Black", "", 1 )}
)

If you post a mock up up how you add the reference lines, I can show a script to add a button box to force the rescale. I will not be able to test it, since I do not have JMP 11, but I think it will work.

 

 

 

Stefan
Level III

Re: Graph builder won't autoscale

Hi, the one way I found Graph Builder would keep the X axis date settings I want and allow rescale with these settings upon filtering is to change the date to "ordinal" data type