Subscribe Bookmark RSS Feed

Change font color within TableBox with JSL

ABI

Community Trekker

Joined:

Jun 23, 2016

Is it possible to change the font color for individual cells within a Tablebox?

 

I found an older post that said this wasn't possible without conditional formatting: https://community.jmp.com/t5/Discussions/Is-there-a-way-to-send-a-font-color-to-a-single-value-in-a/...

 

And conditional formatting won't work for this project. I was hoping this functionality had been added since the older post was made.

 

Essentailly, what I have is a graph with a corresponding table below it. I want the font color for each row to correspond to the line color on the graph.

 

I've tried setting the tablebox's row background colors with "SetSelectedRowColor", but it is ugly and illegible. Changing the font color would be far better, if it is possible. 

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

For part 1., you can do:

New Table( "Untitled 114",
	Add Rows( 10 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
	)
);
Wait(2);
:Column 1 << set Property( "Value Colors", Color Theme( "White to Blue" ) );
:Column 1  << colorCellByValue;
Wait(2);
:Column 1 << set Property( "Value Colors", Color Theme( "Light" ) );

 For part 2., are you able to share a table with just a few rows and a saved Graph Builder script of what you want?

10 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

Looks like '<< textColor()' still acts globally on the contents of 'StringColBox()'.

 

I suppose you could build your own key with 'TextBox()':

 

NewWindow("Legend",
	LineUpBox(NCol(2),
		TextBox("Some Text: "), tb1 = TextBox("Males", << fontColor("Red")),
		TextBox("Some Text: "), tb2 = TextBox("Females", << fontColor("Blue"))
	)
);
ABI

Community Trekker

Joined:

Jun 23, 2016

Hi Ian,

Thanks for the help. To save time, I'm thinking about simply adding a new column at the beginning of the data table ("ID") before it is converted into a tablebox, fill it with i++, and use value colors and a default color theme (JMP Light) to assign the background colors.

 

This way we can easily generate the colors, and the actual text is still legible. It's not ideal, but it should be get the point across.

 

I'm running into two issues, though:

  1. Assigning the Value Colors for a column via JSL
    1. I tried stealing this through the table script:
      New Table( "Untitled 114",
      	Add Rows( 10 ),
      	New Column( "Column 1",
      		Numeric,
      		"Continuous",
      		Format( "Best", 12 ),
      		Set Property(
      			"Value Colors",
      			{1 = 35, 2 = 36, 3 = 37, 4 = 38, 5 = 39, 6 = 40, 7 = 41, 8 = 42, 9 = 43,
      			10 = 44}
      		),
      		Color Cell by Value,
      		Set Selected,
      		Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
      	)
      )
      What I would really like to do is have SetProperty("Value Colors", "JMP Light") instead of the list in the table script. Is there a way to do this?
    2. When Graph Builder takes in <<CategoricalColorTheme("JMP Light"), the palette itself changes but the order of the colors is different
      1. I.e., JMP default (and jmp light) go red->green->blue->orange->etc, whereas graph builder goes blue->red->green->purple-> etc
      2. Essentially, I need a list of the colors that graph builder uses for my subtables.
      3. An alternative would be  assinging colors in the datatable and then having Graph Builder use those colors instead of a palette, but the data is being subsetted and split into multiple graphs/tables based on user interaction -- so while it is possible to do, it would be much easier just to get a list of default colors used by graph builder in the correct order.

Thanks again!

 

ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

For part 1., you can do:

New Table( "Untitled 114",
	Add Rows( 10 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
	)
);
Wait(2);
:Column 1 << set Property( "Value Colors", Color Theme( "White to Blue" ) );
:Column 1  << colorCellByValue;
Wait(2);
:Column 1 << set Property( "Value Colors", Color Theme( "Light" ) );

 For part 2., are you able to share a table with just a few rows and a saved Graph Builder script of what you want?

ABI

Community Trekker

Joined:

Jun 23, 2016

Thanks again, Ian, this helps me greatly. I've got a good battle plan lined up to get this working now.

 

Although it's no longer relevant, to elaborate more on #2 -- when Value Colors are applied to a column, the sequential order of the colors that occur within the column are different than when the theme is used in graph builder.

 

In this image, the "Theme Color" column is a column that I filled 1 to 20, and then hit Value Colors->Color By Value->JMP Light.

The "GB Color" column is a column that I manually made that shows the sequential color order that appears in Graph Builder when JMP Light is applied to the graph.

Capture.JPG

 

After the 12th entry, the colors sync up, but before that they do not correspond to the sequential order within the JMP Light theme.

 

Not really important anymore, but I do still find this to be fairly strange behavior. Do you know why Graph Builder scrambles up the first 12 colors in the color theme?

 

Thanks again for all your time and help,

-Adam

 

 

ian_jmp

Staff

Joined:

Jun 23, 2011

Many thanks for taking the time to document this, Adam. I'll bring it to the attention of R&D.

XanGregg

Staff

Joined:

Jun 23, 2011

The scrambling is my fault. Outside of Graph Builder, JMP will skip green when it needs two colors to avoid the common red/green color deficiency. However, Graph Builder is a little more dynamic and needs to be able to go from two to three colors without changing the first two colors, so it rearranges them from the start (each group of 3 gets a rotation around the color wheel). This only happens with the "JMP"-labeled color themes, so you avoid the dual sequencing by using a different color theme.

 

ABI

Community Trekker

Joined:

Jun 23, 2016

Haha, "fault" is a bit harsh -- this rationale makes perfect sense, thanks for the information :)

pmroz

Super User

Joined:

Jun 23, 2011

You can set the colors of text in a table box.  You have to use col boxes.  Here's an example:


// Col Box Examples
nw = New Window( "Mountains",
	tb = Table Box(
		sb = String Col Box( "Mountain",
			{"K2", "Delphi", "Kilimanjaro", "Grand Teton"}),
// Text boxes of different colors
		cc = col box("Name", 
			tb1 = textbox("Hello"),
			tb2 = textbox("World"),
			tb3 = textbox("Fubar"),
			tb4 = textbox("Geronimo")
		),
	),
);

tb1 << font color("Red") << set font style("Bold");
tb2 << font color("Blue");
tb3 << font color("Green");
tb4 << font color("Orange") << set font style("Bold");
SamH

Contributor

Joined:

Mar 3, 2017

Hi is there a way to color selected cells? I have a hew hundred cells that are selected and I would like to give a color to stand out.

Thanks

Sam