cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
aatw
Level III

Data bars in table

Hi,

is it possible to add data bars in JMP data table, in a similar fashion as in Excel? The closest I can come to is Color Gradient properties in Columns, but data bars would be preferred.

aatw_0-1760694988792.jpeg

 

7 REPLIES 7
jthi
Super User

Re: Data bars in table

Easiest would be to use Tabulate

jthi_0-1760695890855.png

or Table Box() with Col Plot Box()

jthi_1-1760696057284.png

 

-Jarmo
jthi
Super User

Re: Data bars in table

You could also try to play around with different display boxes and then use << get picture. For example for Big Class JMP Table using following as your formula (Expression data type)

Eval(
	Eval Expr(
		Graph Box(
			Frame Size(Col Max(:weight) * 10, 300),
			Y Scale(0, 100),
			X Scale(0, Expr(Col Max(:weight))),
			Fill Color("Red");
			Rect(0, 100, Expr(:weight), 0, 1);
			Text Color("Black");
			Text Size(200);
			Text(Center Justified, {Expr(:weight / 2), 20}, Expr(Char(:weight)));
		)
	)
) << get picture

You will end up with something like

jthi_1-1760720627718.png

 

 

-Jarmo
hogi
Level XIII

Re: Data bars in table

wow!

hogi
Level XIII

Re: Data bars in table

hard to find: suppressaxes
what is doubleBuffer?


hogi_0-1760775683171.png

 

jthi
Super User

Re: Data bars in table

Also, if you do not need the text inside bars, you could use Spacer Boxes instead of Graph Box. Below is quick and very hacky example (I will write better version when I have slightly more time to think about this)

Names Default To Here(1); 

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

dt << New Column("R", Expression, None, Formula(
	As Constant(
		left_color = "Red";
		right_color = "Green";
		minval = Col Min(:Weight);
		maxval = Col Max(:Weight);
		
		scaling = (maxval - minval) / 300;
		
		If(minval >= 0,
			minval = 0;
		);
		If(maxval <= 0,
			maxval = 0
		);
	);
	
	If(:Weight >= 0,
		right = :Weight;
		right_filler = maxval - :Weight;
		left_filler = Abs(minval);
		left = 0;
	,
		left = Abs(:Weight);
		left_filler = Abs(minval) - left;
		right_filler = maxval;
		right = 0;
	);
	
	H List Box(align("Center"),
		Spacer Box(Size(1, 20), Color("Black")),
		Spacer Box(Size(left_filler * scaling, 20), Color("White")),
		Spacer Box(size(left * scaling, 20), color(left_color)),
		Spacer Box(Size(1, 20), Color("Black")),
		Spacer Box(size(right * scaling, 20), color(right_color)),
		Spacer Box(Size(right_filler * scaling, 20), Color("White")),
		Spacer Box(Size(1, 20), Color("Black"))
	);
));

jthi_1-1760799831992.png

With negative values:

jthi_0-1760799737303.png

Also, if you would like to have feature like this in JMP, create post to JMP Wish List

-Jarmo
hogi
Level XIII

Re: Data bars in table

wow, many orders of magnitude faster!

jthi
Super User

Re: Data bars in table

I would have edited my earlier post, but this new community layout has made user experience worse than it was before... so I will create new message (I would have liked to add spoiler tags to the JSL)

jthi_0-1760803998675.png

/*""" Create databar column function

Author: jthi
Creation Date: 2025-10-18
Creation JMP Version: JMP Pro 18.2.1
	
"""*/

Names Default To Here(1); 

add_databar_column = function({dt, colname, leave_formula = 1}, {Default Local},
	newcol = Eval(Substitute(
		Expr(dt << New Column(colname || " Data Bar", Expression, None, Formula(
			As Constant(
				left_color = -15775706; // pinkish
				right_color = -11393916; // light green
				minval = Col Min(_colref_);//, Excluded());
				maxval = Col Max(_colref_);//, Excluded());

				If(minval >= 0,
					minval = 0;
				);
				If(maxval <= 0,
					maxval = 0
				);
				
				scaling = (maxval - minval) / 100;
				
			);
			
			If(_colref_ >= 0,
				right = _colref_;
				right_filler = maxval - _colref_;
				left_filler = Abs(minval);
				left = 0;
			,
				left = Abs(_colref_);
				left_filler = Abs(minval) - left;
				right_filler = maxval;
				right = 0;
			);
			
			bb = Border Box(Top(2), Bottom(2), Sides(15),
				H List Box(align("Center"),
					Spacer Box(Size(left_filler / scaling, 13), Color("White")),
					Spacer Box(size(left / scaling, 13), color(left_color)),
					Spacer Box(size(right / scaling, 13), color(right_color)),
					Spacer Box(Size(right_filler / scaling, 13), Color("White")),
				),
				<< Backgroundcolor("White")
			);			
		))),
		Expr(_colref_), Name Expr(AsColumn(dt, colname));
	));
	
	If(!leave_formula,
		dt << Run Formulas;
		newcol << Delete Formula;
	);
	
	newcol << Set Display Width(110);
	return(newcol);
);

/*
// Example
dt = open("$SAMPLE_DATA/BabySleep.jmp");

add_databar_column(dt, "Awake");
add_databar_column(dt, "Asleep");
add_databar_column(dt, "Dif");
*/
-Jarmo

Recommended Articles