cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

Dynamic color

hcarr01
Level VI
Hello everyone,

I use the chart builder in JMP.
From the columns of my database, I create measures (indicators) directly in the chart builder to display them.

For example with my column A and my column B, I create the measure with the formula AB.
This measurement refers to an indicator that I add to my graph just below the title.

The problem is that I would like to give a color to the measure I create based on the value of that measure.

I would like to be able to put the text in green if the measurement is > 0 and put the text in red if the measurement is < 0.

For the moment, I can associate a color with the measurement but the color is not dynamic it does not change depending on the values.

Is there a way to get around this problem?

This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .

2 REPLIES 2
SDF1
Super User


Re: Couleur dynamique

Hi @hcarr01 ,

 

  I'm not exactly sure what it is you're wanting to do, but I think I understand. This is one way to do it by using the JSL code below -- you can see how it's done on the Big Class.jmp file. Here, I just chose to color :age <=14 red and >=15 green.

Names Default to here(1);

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

For(i=1, i<=NRows(), i++,
	If(
		:age[i]<=14,
		:age<<Color Cells("red", i),
		:age[i]>=15,
		:age<<Color Cells("green", i),
	)
);

  Another option would be to set a Spec Limit for the column and use Analyze > Quality and Process > Manage Limits and then use the red hot-button to color out of spec cells. The default here is blue if > USL and red if < LSL, and I don't think you can edit this in the preferences.

 

One of these options should get you to where you want to go, I think. If you want to color the row state, then you could also try the Color by Column() command. See the Scripting Index example:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Color by Column( :Age );
Wait( 2 );
dt << Color Rows by Row State;

  The last command will also color the rows according to how they've been assigned in Color by Column.

 

  Definitely one of these options should get you what you're after.

 

Good luck!,

DS

  

  

hcarr01
Level VI

Re: Couleur dynamique

Dans le constructeur de graphique, je créé une mesure à partir de la capture ci-dessous :

 

hcarr01_0-1707376359074.png

 

Une fois que la nouvelle mesure est créé par exemple Transformation[B] = A - B je la rajoute dans le graphique comme dans capture ci-dessous :

 

hcarr01_1-1707376514394.png

Est-il possible de modifier la couleur de la mesure Transformation[B] en fonction des valeurs ?

 

 

J'ai essayé avec le script suivant mais rien ne se passe, aucune couleur ne s'affiche sur le graphique !

 

Graph Builder(
	Transform Column(
		"indicateurs (A-B)",
		Formula( Col Sum( :A ) - Col Sum( :B ) )
	),
	Size( 534, 450 ),
	Show Control Panel( 0 ),
	If( indicateurs (A-B) < 0,
			Title Fill Color( "Light Red" ),
			Title Frame Color( "Light Red" ),
			Level Fill Color( {255, 193, 202} ),
			Level Frame Color( "Light Red" ),
			Level Spacing Color( "Light Red" ),
			,
			Title Fill Color( "Light Green" ),
			Title Frame Color( "Light Green" ),
			Level Fill Color( {190, 255, 202} ),
			Level Frame Color( "Light Green" ),
			Level Spacing Color( "Light Green" ),			
	),
	Variables(
		X( :Mois ),
		Y( :A ),
		Y( :B, Position( 1 ) ),
		Group X( :"indicateurs (A-B)"n )
	),
	Elements( Bar( X, Y( 1 ), Y( 2 ), Legend( 5 ), Label( "Label by Value" ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				5,
				Properties( 0, {Fill Color( 51 )}, Item ID( "A", 1 ) ),
				Properties( 1, {Fill Color( 21 )}, Item ID( "B", 1 ) )
			)}
		)
	)
);