cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
miguello
Level VI

How to limit number of legend items?

I have a plot that is overlayed by hundreds of catergorical values. When user works with it, it only makes sense to compare 2, 3, maximum 5 categories, and user id doing that through data filter.

But nothing prevents user from selecting all 150+ categories. In this case they all get displayed in legend, totally breaking windows. Since you wouldn't be able to see anything on the plot in this case anyways, I'm OK with just limiting number of legend items to, let's say, 20, so it doesn't break the design and still serves the purpose. Any way to specify the limit through JSL?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
miguello
Level VI

Re: How to limit number of legend items?

Ok, I got it.

Calculate the number of categories:

Categories = NItems(Associative Array (dt:CategoriesColumn));

Set up how many legend items you want:

LegendLevels = 3;

Construct a list that has the same number of elements as how many categories you have, fill it with consecutive numbers for the levels you want to show, and "-1" for the rest:

p = {};
	For(i=0, i < Categories, i+=1,
		if(i <= (LegendLevels-1), p = Insert(p, i), p = Insert(p, -1))
		);

The use this list when scripting your Graph Builder, inside SendToReport():

		Dispatch(
			{},
			"400",
			LegendBox,
			{Set Title( "Category" ), Legend Position( {5, Matrix(p)} ),
			Position( Matrix(p) )}
		)

View solution in original post

1 REPLY 1
miguello
Level VI

Re: How to limit number of legend items?

Ok, I got it.

Calculate the number of categories:

Categories = NItems(Associative Array (dt:CategoriesColumn));

Set up how many legend items you want:

LegendLevels = 3;

Construct a list that has the same number of elements as how many categories you have, fill it with consecutive numbers for the levels you want to show, and "-1" for the rest:

p = {};
	For(i=0, i < Categories, i+=1,
		if(i <= (LegendLevels-1), p = Insert(p, i), p = Insert(p, -1))
		);

The use this list when scripting your Graph Builder, inside SendToReport():

		Dispatch(
			{},
			"400",
			LegendBox,
			{Set Title( "Category" ), Legend Position( {5, Matrix(p)} ),
			Position( Matrix(p) )}
		)