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
LT
LT
Level I

Color cells by specific condition

Hi,

 

I'm new for JSL.

I want the cell to change color based on specific condition.

for example, I want :dIGSS>5 get red color.

 

dt << Get Rows Where(:dIGSS>5);
:dIGSS << Color Cells(3);

But all dIGSS rows change to red. 

 

I've found an example which can change cell's color based on specific condition, but it is for each column:

For Each({colname}, dt << Get Column Names("String"),
 rows_to_color = dt << Get Rows Where((Column(dt, colname)[]>5));
 Column(dt, colname) << Color Cells("Red", rows_to_color);
);

How can I do?

I have version 17.

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Color cells by specific condition

You can provide Color Cells with list of rows numbers (or matrix) and you can then use that (basically remove loop from your second example)

rows_to_color = dt << Get Rows Where(:dIGSS > 5));
:dIGSS << Color Cells("Red", rows_to_color);

See example 2 (and 3 if you need multiple colors) from Scripting Index for Color Cells

jthi_0-1703854434383.png

 

Edit:

Corrected text "You can provide Color Cells with list of columns" to "You can provide Color Cells with list of row numbers"

-Jarmo

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Color cells by specific condition

Examining the issue, using the Scripting Index, there does not seem to be any "Color Cells" syntax that permits the coloring of cells for more than one column using JSL.  There is a syntax for "Color Cells" that is used in conjunction with the Identifying of Outliers platform.

Therefore, the sample JSL you listed is the only method I know of to color the cells as you want.

Jim
jthi
Super User

Re: Color cells by specific condition

You can provide Color Cells with list of rows numbers (or matrix) and you can then use that (basically remove loop from your second example)

rows_to_color = dt << Get Rows Where(:dIGSS > 5));
:dIGSS << Color Cells("Red", rows_to_color);

See example 2 (and 3 if you need multiple colors) from Scripting Index for Color Cells

jthi_0-1703854434383.png

 

Edit:

Corrected text "You can provide Color Cells with list of columns" to "You can provide Color Cells with list of row numbers"

-Jarmo
LT
LT
Level I

Re: Color cells by specific condition

Thanks! This is exactly what I need.