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
NaiveJaguar366
Level II

Alternate row shading colors

I have alternate row shading set to 1 in my script and the rows in my data tables are coloured in shades of greys, I would like to change the colors used, to two shades of blue. What is the best way to code this in jsl.

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: Alternate row shading colors

This code should give you an idea how to do it for a data table.

dt = New Table( "Test Banding", Add Rows( 4 ),
	New Column( "Column 1", Character, "Nominal",
		Set Values( {"a", "b", "c", "d", "e"} ) ),
	New Column( "Column 2", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [3, 2, 1, 0, -1] ) ),
	New Column( "Column 3", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [4, 5, 6, 7, 8] ) )
);

// Create a list of every other row number
gray_rows = {};
for (i = 1, i <= nrows(dt), i+=2,
	insertinto(gray_rows, i);
);

// Set every other row to gray
for (i = 1, i <= ncols(dt), i++,
	column(dt, i) << Color Cells( {-14803425, gray_rows} );
);

pmroz_0-1650368978851.png

 

View solution in original post

4 REPLIES 4
ErraticAttack
Level VI

Re: Alternate row shading colors

Your question is a bit sparse.  If you're asking about a TableBox() then I do believe that it's not possible to set which colors the rows are shaded, just the default grays.  If you're talking about a DataBox() (as you would get when opening a "*.jmp" file), then you can set the cell colors to whatever you'd like -- just look up "color cell" in the Scripting index.

Jordan
NaiveJaguar366
Level II

Re: Alternate row shading colors

Thanks for replying, I will look up databox solution.
pmroz
Super User

Re: Alternate row shading colors

This code should give you an idea how to do it for a data table.

dt = New Table( "Test Banding", Add Rows( 4 ),
	New Column( "Column 1", Character, "Nominal",
		Set Values( {"a", "b", "c", "d", "e"} ) ),
	New Column( "Column 2", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [3, 2, 1, 0, -1] ) ),
	New Column( "Column 3", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [4, 5, 6, 7, 8] ) )
);

// Create a list of every other row number
gray_rows = {};
for (i = 1, i <= nrows(dt), i+=2,
	insertinto(gray_rows, i);
);

// Set every other row to gray
for (i = 1, i <= ncols(dt), i++,
	column(dt, i) << Color Cells( {-14803425, gray_rows} );
);

pmroz_0-1650368978851.png

 

NaiveJaguar366
Level II

Re: Alternate row shading colors

Thanks for taking the time to include an example. This is just what I was looking for, still new to JSL coding.

 

Many thanks for your help.

 

Craig.