Choose Language Hide Translation Bar
Highlighted
tom_abramov
Level V

Show/Hide Labels due to number of bars

Hi,

What is the way in JSL to know how many bars a Graph Builder Bar chart has?

If there are many bars (>20), I would like to hide bar labels.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Show/Hide Labels due to number of bars

You can check to see what the Min, Max and Inc for the axis of interest is, determine the number of bars from that, an then set the labeling as desired.

Jim

View solution in original post

5 REPLIES 5
Highlighted
txnelson
Super User

Re: Show/Hide Labels due to number of bars

You can check to see what the Min, Max and Inc for the axis of interest is, determine the number of bars from that, an then set the labeling as desired.

Jim

View solution in original post

Highlighted
tom_abramov
Level V

Re: Show/Hide Labels due to number of bars

Thank you Jim.

@txnelson 

Another question: What is the syntax of adding labels after creating the chart.

The following doesn't work

gb = Graph Builder(
	Variables( X( :age ), Y( :height ), Group Y( :sex ) ),
	Elements( Bar( X, Y, Legend( 1 )  ) )
);

gb <<  Label( "Label by Value" );

 

Highlighted
txnelson
Super User

Re: Show/Hide Labels due to number of bars

The various labels are all accessible via the Tree Structure of the Output Report.  To learn about the them, read the sections in the Scripting Guide on Display Trees.  The Scripting Guide can be found in the JMP Documentation Library.

     Help==>JMP Documentation Library

treestr.PNG

Here is a little script that changes the various Labels on this style of graph

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

gb = Graph Builder(
	Variables( X( :age ), Y( :height ), Group Y( :sex ) ),
	Elements( Bar( X, Y, Legend( 1 ) ) )
);

gbr = gb << report;

gbr[Text Edit Box( 1 )] << set text( " This is the Header" );
gbr[Text Edit Box( 4 )] << set text( " This is the Y Axis Label" );
gbr[Text Edit Box( 3 )] << set text( " This is the X Axis Label" );
Jim
Highlighted
tom_abramov
Level V

Re: Show/Hide Labels due to number of bars

Thanks Jim and sorry for unclarity.

I ment labels of bars (Label by value), not axises.

@txnelson 

Highlighted

Re: Show/Hide Labels due to number of bars

The Bar element depends on the levels of the grouping variable. So you could also use the Summarize() function to determine the number of bars.

Learn it once, use it forever!
Article Labels