Subscribe Bookmark RSS Feed

Treemap JSL: How to show all the data with colored local data filter?

vishwasanj

Frequent Contributor

Joined:

Dec 27, 2016

Hi,

 

Is it possible to show all of the data in a treemap in 1 color and color code specific part through a different color?

 

 

1 REPLY
melaniedrake

Staff

Joined:

May 30, 2014

There isn't a way within treemap to do this. However, you could create a column to use as the Color column for your treemap. If all the values of that column are the same, then all the squares in the treemap are the same color. Changing the values in that color column that correspond to the category you want to highlight will make that one square a different color. You could put that into a formula in the color column.

 

Or, here's a dynamic example that lets you filter. It only works on one selected value, but you could certainly complicate the script and make it work with multiple category selections. Note that I'm using a numeric variable as the category variable, while I need strings to populate the list box. If your category variable is a character column, that makes it a little easier.

 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column( "color", 
	"Numeric", "Nominal", Set Values(J( nrows(dt), 1, 1 ))
);

ages = Associative Array( dt:age ) << get keys;
For( i = 1, i <= N Items(ages), i++, ages[i] = char(ages[i]) );
age groups = Associative Array( ages, Associative Array(dt:age) << get keys );

dt << Treemap( Categories( :age ), Coloring( :color ), Color Theme( "JMP Default" ) );
New Window( "Select an age", c = List Box( age groups << get keys, Max Selected(1), If(c << get selected == {}, dt:color[1::nrows(dt)] = 1, For Each Row( If( dt:age == age groups[(c << get selected)[1]], dt:color = 2, dt:color = 1 ) ) ) ) );