cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Kelly
Level III

How do I set a color to a specific value in a data table based on limits from other columns?

 

I am trying to color cells in jsl based on if they are over, under, or between limits. In this case Amanda is too short for the roller coaster so I want the box to be blue. Jeff is too tall, so I want the box to be red. Luke meets the requirement for the water slide, so that box can be green.

 

Kelly_0-1576279495315.png

 

I went into column properties and tried "value colors" but that will not work for me because you must already know what colors you want to assign to what values. Certain values will need to take on different colors based on the ride limit. Sometimes a height of 66 will be green, but for a different ride it maybe too tall, and therefore red.
I also tried "color gradient" this will not work because it uses many shades or blue, red, and green. I only want 3 colors.

Is there a way to make the table above using jsl?

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I set a color to a specific value in a data table based on limits from other columns?

You can use the "Color Cells() message to change the cell color for specific cells.  See the Scripting Index for definition and examples.  Below is a simple script that covers your example data table

 

example.PNG

Names Default To Here( 1 );

dt = New Table( "example",
	Add Rows( 4 ),
	New Column( "User", Character, "Nominal", Set Values( {"Amanda", "Jeff", "Kim", "Luke"} ) ),
	New Column( "Ride", Character, "Nominal", Set Values( {"Rollarcoaster", "Rollarcoaster", "Water Slide", "Water Slide"} ) ),
	New Column( "Height", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [59, 68, 55, 66] ) ),
	New Column( "Height Minimum", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [60, 60, 65, 65] ) ),
	New Column( "Height Maximum", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [65, 65, 70, 70] ) )
);
for each row(
	if(:Height Minimum <= :Height <= :Height Maximum,
		dt:Height << color cells("Green", Row()),
		:Height < :Height Minimum,
		dt:Height << color cells("Blue", Row()),
		dt:Height << color cells("Red", Row())
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How do I set a color to a specific value in a data table based on limits from other columns?

You can use the "Color Cells() message to change the cell color for specific cells.  See the Scripting Index for definition and examples.  Below is a simple script that covers your example data table

 

example.PNG

Names Default To Here( 1 );

dt = New Table( "example",
	Add Rows( 4 ),
	New Column( "User", Character, "Nominal", Set Values( {"Amanda", "Jeff", "Kim", "Luke"} ) ),
	New Column( "Ride", Character, "Nominal", Set Values( {"Rollarcoaster", "Rollarcoaster", "Water Slide", "Water Slide"} ) ),
	New Column( "Height", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [59, 68, 55, 66] ) ),
	New Column( "Height Minimum", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [60, 60, 65, 65] ) ),
	New Column( "Height Maximum", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [65, 65, 70, 70] ) )
);
for each row(
	if(:Height Minimum <= :Height <= :Height Maximum,
		dt:Height << color cells("Green", Row()),
		:Height < :Height Minimum,
		dt:Height << color cells("Blue", Row()),
		dt:Height << color cells("Red", Row())
	)
);
Jim
Kelly
Level III

Re: How do I set a color to a specific value in a data table based on limits from other columns?

Thanks!

Recommended Articles