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
Dape
Level II

How to add label name to a legend in a Graph Builder plot through JSL?

I have a script creating a plot using Graph Builder which shows data from measurements. After producing the plot, I loop through the measurements month by month and use the command Add Variable to add monthly calculated curve fits to show the development over time of the recorded data.

Now I'm trying to figure out how I can add a label to each plotted curve fit through script. The column labels for the curve fits are currently something like "June 24 data", "July 24 data", etc. When I right-click the curve fit for each month's data in the legends window, I can add this by selecting Label>Name. This will show the name next to each plotted curve. I can also right-click the plot area, choose Customize and access the name setting for the curve fit but this isn't updated on the plot - and when I go back to the settings it has been deselected. That seems like a bug but maybe I just use it the wrong way. Anyway, I'm trying to find a way to add the label name like this through JSL.

I tried capturing these changes using a workflow, but it doesn't capture the changes I did to the legends' settings.

I've made several searches but can't find any discussion on this specific addition to a plot using JSL, nor can I find documentation of it in the scripting index. There's something called legends server but I couldn't find relevant discussion. Perhaps I can use SendToReport(Dispatch())? Any other variants I should be looking at? I'd also appreciate any suggestion on where I could be learning more about JSL for producing and adjusting plots through Graph Builder.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to add label name to a legend in a Graph Builder plot through JSL?

I think you have to do this through legend server (or when building the graph builder expression)

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Transform Column("Row", Formula(Row())),
	Variables(X(:Row), Y(:height)),
	Elements(Line Of Fit(X, Y, Legend(5), Confidence of Fit(0))),
	SendToReport(
		Dispatch({}, "400", ScaleBox,
			{Legend Model(
				5,
				Properties(
					0,
					{Line Label Properties({Name Label(1)})},
					Item ID("height", 1)
				)
			)}
		)
	)
);

gb << Add Variable({:weight, Role("Y"), Position(1)});

server = gb << Get Legend Server;
items = server << Get Legend Items;
For(i = 1, i <= N Items(items[1]), i++,
	items[1][i] << Set Properties(
		{Line Label Properties({Name Label(1)})}
	)
);
-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: How to add label name to a legend in a Graph Builder plot through JSL?

I think you have to do this through legend server (or when building the graph builder expression)

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Transform Column("Row", Formula(Row())),
	Variables(X(:Row), Y(:height)),
	Elements(Line Of Fit(X, Y, Legend(5), Confidence of Fit(0))),
	SendToReport(
		Dispatch({}, "400", ScaleBox,
			{Legend Model(
				5,
				Properties(
					0,
					{Line Label Properties({Name Label(1)})},
					Item ID("height", 1)
				)
			)}
		)
	)
);

gb << Add Variable({:weight, Role("Y"), Position(1)});

server = gb << Get Legend Server;
items = server << Get Legend Items;
For(i = 1, i <= N Items(items[1]), i++,
	items[1][i] << Set Properties(
		{Line Label Properties({Name Label(1)})}
	)
);
-Jarmo
Dape
Level II

Re: How to add label name to a legend in a Graph Builder plot through JSL?

That solution worked, thank you!

 

Interestingly, when I save the plot with the added labels as an interactive HTML, the labels are not in the plot as I open it. However it is included when I save it as a regular HTML-file and open it. I thought I'd mention in case anyone else follows this approach and in case you want to register it as a bug, also because your solution is documented here so it will be easier to reproduce.

jthi
Super User

Re: How to add label name to a legend in a Graph Builder plot through JSL?

Which JMP version do you have? Based on very quick test it seems to work in JMP18.1

jthi_0-1727434656577.png

 

-Jarmo
Dape
Level II

Re: How to add label name to a legend in a Graph Builder plot through JSL?

Ah, that's good to know, I'm using version 17.0.0. And when I check the message log, it says that "Line labels are not supported and are omitted from the report." so it's not a bug, should have checked there first apparently.

Thanks for the reply!

 

Saving it as an image instead also works, the line labels are included, that's what the regular html saving does.

Re: How to add label name to a legend in a Graph Builder plot through JSL?

Hi @Dape , 

 

Thank you for not calling it a bug and reminding JMP User Community readers that when something doesn't appear in the Interactive HTML version or if the interactive HTML version contains non-interactive elements, it's a good idea to look in the log to see if it is a known limitation of Interactive HTML.

 

When a new feature is added to JMP, we often can't support it in Interactive HTML within the same release cycle. Instead we're focusing on features that were added in previous releases that we feel users need the most.

 

We write the "not supported" message to the log when we feel it would be a shame to lose interactivity due to a particular feature we don't support and we use the "not interactive" message when we feel a feature needs to be in the Interactive HTML display at the expense of losing interactivity. 

 

In either case, we invite users to let us know through JMP technical support or the JMP Wish List that support for a particular feature in Interactive HTML is desired since we prioritize our efforts based on user feedback. 

 

You also pointed out that the regular HTML export uses images and display the line labels. This can be a good alternative for cases when our decision to 'omit a feature rather than losing interactivity' works against your needs. 

 

Thanks, 

~John

 

 

Re: How to add label name to a legend in a Graph Builder plot through JSL?

That's correct. Line labels were added to JMP in JMP 17, but were not supported in Interactive HTML until JMP 18. 

Thanks,

~John