cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
TWE
TWE
Level III

Show zero percent in bar chart

Hi,

 

I build a bar chart in percent and need also to display zero percent (in the sniplet group2).

Names Default To Here( 1 );
dt = New Table("Test");
dt << new column ("C", numeric, Continuous);
dt << new column ("D", numeric, Continuous);
dt << new column ("E", numeric, Continuous);
:C << set values([1,2,3]);
:D << set values([1,2,3]);
:E << set values([1,0,0.5]);
dt << new column ("Percent", numeric, Continuous, Format( "Percent", 15, 3 ), Formula(:E/:D));

dt << Graph Builder(
	Size( 534, 454 ),
	Show Control Panel( 0 ),
	Variables( Y( :Percent ), Group X( :C ) ),
	Elements( Bar( Y, Legend( 4 ), Label( "Label by Value" ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Percent",
			ScaleBox,
			{Min( -0.113265306122449 ), Max( 1.08673469387755 ), Inc( 0.2 ),
			Minor Ticks( 0 )}
		)
	)
);

Thanks for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
julian
Community Manager Community Manager

Re: Show zero percent in bar chart

Hi @TWE,

 

I'm not aware of a way to force JMP to display the label for a truly 0 value. It's a bit of a workaround, but what I've done in the past is add a tiny amount to a value so that jmp will round to 0 and display that rounded value. For instance, using your example, by setting the value of :E[2] to 0.000000000000001 rather than 0, the 0% label displays on the graph:

 

 

Names Default To Here( 1 );
dt = New Table("Test");
dt << new column ("C", numeric, Continuous);
dt << new column ("D", numeric, Continuous);
dt << new column ("E", numeric, Continuous);
:C << set values([1,2,3]);
:D << set values([1,2,3]);
:E << set values([1,0.000000000000001,0.5]);
dt << new column ("Percent", numeric, Continuous, Format( "Percent", 15, 3 ), Formula(:E/:D));

dt << Graph Builder(
	Size( 534, 454 ),
	Show Control Panel( 0 ),
	Variables( Y( :Percent ), Group X( :C ) ),
	Elements( Bar( Y, Legend( 4 ), Label( "Label by Value" ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Percent",
			ScaleBox,
			{Min( -0.113265306122449 ), Max( 1.08673469387755 ), Inc( 0.2 ),
			Minor Ticks( 0 )}
		)
	)
);

 

 

View solution in original post

3 REPLIES 3
julian
Community Manager Community Manager

Re: Show zero percent in bar chart

Hi @TWE,

 

I'm not aware of a way to force JMP to display the label for a truly 0 value. It's a bit of a workaround, but what I've done in the past is add a tiny amount to a value so that jmp will round to 0 and display that rounded value. For instance, using your example, by setting the value of :E[2] to 0.000000000000001 rather than 0, the 0% label displays on the graph:

 

 

Names Default To Here( 1 );
dt = New Table("Test");
dt << new column ("C", numeric, Continuous);
dt << new column ("D", numeric, Continuous);
dt << new column ("E", numeric, Continuous);
:C << set values([1,2,3]);
:D << set values([1,2,3]);
:E << set values([1,0.000000000000001,0.5]);
dt << new column ("Percent", numeric, Continuous, Format( "Percent", 15, 3 ), Formula(:E/:D));

dt << Graph Builder(
	Size( 534, 454 ),
	Show Control Panel( 0 ),
	Variables( Y( :Percent ), Group X( :C ) ),
	Elements( Bar( Y, Legend( 4 ), Label( "Label by Value" ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Percent",
			ScaleBox,
			{Min( -0.113265306122449 ), Max( 1.08673469387755 ), Inc( 0.2 ),
			Minor Ticks( 0 )}
		)
	)
);

 

 

TWE
TWE
Level III

Re: Show zero percent in bar chart

Thanks this works well!

Re: Show zero percent in bar chart

Another possible approach can be found in this link:

https://community.jmp.com/t5/Discussions/force-all-histogram-levels-on-bar-graph-even-if-count-0/m-p...

 

It should apply to percents, but I have not tried that.

Dan Obermiller