cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
rbfinner
Level III

Modifying Graph builder legend properties / Documentation for legend Model()

Hi, 

I'm looking for a method to consistently target and modify legend items in graph builder. 

After I've added variables to generate the basic graph, I use the dispatch statements to modify the line-style/color/size. 

The issue that I'm running into is that the legend text (or the item Ids) change depending on what rows I have included/excluded in the data table, and therefore the dispatch statement will work for some selections but not for others. 

 

Example:

LHS, I have multiple rows per x-category (YearMonth). 

The legend text has the format - "Mean(ColumnName)"

RHS, with rows excluded I only have a single row per x-category. 

The legend text has the format - "ColumnName"

rbfinner_1-1657998504036.png

 

rbfinner_0-1657998470939.png

 

 

To modify the legend items I'm using the legend Model (...) statement as below, where Item ID( "Mean(Yield_A)", 1 ) identifies the item to modify.

gb << send to report (
Dispatch(
{},
"400",
ScaleBox,
{Legend Model( 15,
				Level Name( 0, "Yield_A", Item ID( "Mean(Yield_A)", 1 ) ),
				Properties( 0, {Line Color( "red"  ), Line Width( 6 )}, Item ID( "Mean(Yield_A)", 1 ) ),
			)
}
));

I use a data table filter to include/exclude rows to narrow down the graph to a single segment or product. 

When filtered to a single product, there is a single row per YearMonth, and the legend text changes as highlighted in the above RHS graph.

The original Item ID( "Mean(Yield_A)", 1 )  used in the dispatch statement will not find a matching item (the columnname is no longer wrapped in mean()) 

 

One workaround is to duplicate the legend model () statement/s, to target legend text with format of  "ColumnName", e.g. Item ID( "Yield_A", 1 )

 

This works but it is cumbersome. 

 

Qs: 

  1. Is there an alternative / better method to target the legend items that will work for both cases noted above?
  2. Is there any standalone documentation for the legend model() statement or its components (I couldn't find it)?   

 

One last thought... I'm assuming that when there is only a single row/value for each x-category, dropping of the Mean() wrapper in the legend text is intentional, but perhaps it would make sense still have the legend item display as "Mean(columnName)", even when there is only a single value? After all, the summary statistic for the line element is still set to "Mean".

 

Thanks, 

Ray

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Modifying Graph builder legend properties / Documentation for legend Model()

Check Scripting Index for Legend Server, it allows you to change legend labels at least (documentation is fairly bad for Legend Server though)

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Variables(X(:height), Y(:weight), Overlay(:sex), Color(:age)),
	Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
);
server = gb << Get Legend Server;
items = server << Get Legend Items;
For Each({item, index}, items[1], item << Set Label("Item " || Char(index)));
-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Modifying Graph builder legend properties / Documentation for legend Model()

Check Scripting Index for Legend Server, it allows you to change legend labels at least (documentation is fairly bad for Legend Server though)

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Variables(X(:height), Y(:weight), Overlay(:sex), Color(:age)),
	Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
);
server = gb << Get Legend Server;
items = server << Get Legend Items;
For Each({item, index}, items[1], item << Set Label("Item " || Char(index)));
-Jarmo
rbfinner
Level III

Re: Modifying Graph builder legend properties / Documentation for legend Model()

It looks like Legend Server is a JMP16 addition.

Although I have JMP16 installed most of my org are still using JMP14 or JMP15. 

I'm building a JMP GUI to share with the team, so I will need to stick with JMP15 for now. 

@jthi- thank you for the inputs - I will definitely use this in the future (just not right now). 

rbfinner
Level III

Re: Modifying Graph builder legend properties / Documentation for legend Model()

I accepted the above as a solution, but it works for JMP16 only. So still open to other suggestions/options that might work with JMP15. Thanks