cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
LargeCanary830
Level II

Color cells

Hi, 

 

How I can gray-out empty or with dots cells? 

LargeCanary830_0-1698870672818.png

I have version 16.1. 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Color cells

Depending on how this will be used, there are few options. Simplest option and what will get you going is to open new script file from File menu

jthi_0-1698928278797.png

Then copy paste the script to that window which will open

jthi_1-1698928311292.png

Check that you have correct table from the top "toolbar" (it should be if it was last active when you did open the new script file).

Then Press Run Script from the toolbar

jthi_2-1698928352209.png

 

If this must be done repeatedly, you could make that script into a toolbar item, add-in, table script, script file... depending on the use

 

-Jarmo

View solution in original post

9 REPLIES 9
mmarchandTSI
Level V

Re: Color cells

If you want it done to each column, you could use this script.

For Each( {col}, dt << Get Column Names( "String" ),
	Eval(
		Eval Expr(
			dt << Select Where( Is Missing( As Column( Expr( col ) ) ) );
			Expr( Column( col ) ) << Color Cells( "gray" );
			dt << Clear Select;
		)
	)
);

*edit

The Expr() and all that are completely unnecessary.  @jthi pointed that out with his example.

For Each( {col}, dt << Get Column Names( "String" ),
	dt << Select Where( Is Missing( As Column( col ) ) );
	Column( col ) << Color Cells( "gray" );
	dt << Clear Select;
);

 

jthi
Super User

Re: Color cells

@mmarchandTSI you might also want to add check that some rows are selected (<< Color Cells will otherwise color all the cells).

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([., ., 1])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
	New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([2, 3, 4]))
);

For Each({col}, dt << Get Column Names("String"),
	dt << Select Where(Is Missing(As Column(col)));
	Column(col) << Color Cells("gray");
	dt << Clear Select;
);
/*
For Each({col}, dt << Get Column Names("String"),
	dt << Select Where(Is Missing(As Column(col)));
	If(N Items(dt << Get Selected Rows) > 0,
		Column(col) << Color Cells("gray");
	);
	dt << Clear Select;
);
*/
-Jarmo
mmarchandTSI
Level V

Re: Color cells

Should be okay, because <<Select Where only adds to the current selection when the "extend" option is specified.  Default is to select only rows that satisfy the conditions.  Could amend the <<Select Where to be safe.

dt << Select Where( Is Missing( As Column( col ) ), current selection( "clear" ) )
jthi
Super User

Re: Color cells

What I meant is that if there are no rows selected at all, all the cells in that column will be colored.

 

In this case all the cells in Age will get colored because there are no rows selected

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
wait(1);

:Age << Color Cells("Red");
wait(1);

dt << Select Rows([2,4,6,20]);
:Name << Color Cells("Blue");
dt << Clear Select;

jthi_0-1698927597379.png

 

-Jarmo
mmarchandTSI
Level V

Re: Color cells

Yes, good point.

jthi
Super User

Re: Color cells

If by graying-out you mean changing the cell color, easiest options are most likely script based. One option is using << Get Rows Where to get the rows which you want to color and then using << Color Cells to set the color to those rows

Names Default To Here(1);

dt = Current Data Table();

For Each({colname}, dt << Get Column Names("String"),
	rows_to_color = dt << Get Rows Where(Is Missing(Column(dt, colname)[]));
	Column(dt, colname) << Color Cells("Gray", rows_to_color);
	dt << Clear Select;
);

jthi_0-1698905312308.png

 

-Jarmo
LargeCanary830
Level II

Re: Color cells

Hi Jarmo,

 

Where can I add this option? sorry I'm new using JMP software. 

jthi
Super User

Re: Color cells

Depending on how this will be used, there are few options. Simplest option and what will get you going is to open new script file from File menu

jthi_0-1698928278797.png

Then copy paste the script to that window which will open

jthi_1-1698928311292.png

Check that you have correct table from the top "toolbar" (it should be if it was last active when you did open the new script file).

Then Press Run Script from the toolbar

jthi_2-1698928352209.png

 

If this must be done repeatedly, you could make that script into a toolbar item, add-in, table script, script file... depending on the use

 

-Jarmo
LargeCanary830
Level II

Re: Color cells

Perfect! Thank you for your help. I really appreciate it.