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

How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

For example, the name column of Big Class.jmp automatically sets the color gradient of the name based on the value of the height column
It is required to be done in script.

Thanks!

2023-10-18_9-58-29.png

16 REPLIES 16
txnelson
Super User

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

Here is the only way I know how to do it

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
a = {1, 3, 5};
b = {2, 4, 6};
:height << color cells( {{"Red", a}, {"blue", b}} );
theScript = Char( :height << get script );
theScript = Substr( theScript, Contains( theScript, "Color Cells" ) );
theScript = ":Name<<" || Substr(
	theScript,
	1,
	Contains( theScript, "Set Value" ) - 3
);
Eval( Parse( theScript ) );

txnelson_0-1697603936194.png

 

Jim
lala
Level VII

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

Thank Jim!

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
m= 4 ;Column(m)<<set property("Color Gradient",{"Green to White to Red",Range({col min(Column(m)),col max(Column(m)),col mean(Column(m))})})<<Color Cell by Value;

//??
theScript = Char( :height << get script );
theScript = Substr( theScript, Contains( theScript, "Color Cells" ) );
theScript = ":Name<<" || Substr(
	theScript,
	1,
	Contains( theScript, "Set Value" ) - 3
);
Eval( Parse( theScript ) );
txnelson
Super User

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

I do not have a solution for a gradient color pattern.  

Jim
lala
Level VII

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

Thank Jim!

 

How do I get the fill color of a cell using JSL?

jthi
Super User

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

One place where you could get the color is from report html. You will have to perform conversion though

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
m = 4;
Eval(EvalExpr(
	Column(dt, m) << set property(
		"Color Gradient",
		{"Green to White to Red", Range({Expr(Col Min(Column(m))), Expr(Col Max(Column(m))), Expr(Col Mean(Column(m)))})}
	) << Color Cell by Value;	
));

(dt << get as report) << get html;
-Jarmo
lala
Level VII

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

  • Complex I will not operate, can use the script to achieve?

Thanks Experts!

2023-10-18_17-15-39.png

jthi
Super User

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

Also depending on how the gradient is created, you could maybe use Value Colors instead of Gradient column property. Then you can get the colors from column properties.

-Jarmo
lala
Level VII

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

txt = dt << get as report;
txt << Save HTML( "c:\tt.html" );
u = "c:\tt.html";
For( k = 0, k <= 60, k++,
	Try( d1 = Open( u, HTML Table( k, Column Names( 1 ), Data Starts( 2 ) ) ) );
	Wait( 0 );
);
lala
Level VII

Re: How to use JSL to set the color gradient of a column in text format by the value of a numeric column?

Ask experts how to use RE to get these content?

How do I set the color in the name column after I get this?

 

Thanks!