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.
Choose Language Hide Translation Bar
View Original Published Thread

labels in a chart

Françoise
Level V

Good morning,


Is there a trick in jsl to display labels from a certain value that we could choose? for this graph, we would only display labels for the largest values.


Sincerely


undefined

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

1 ACCEPTED SOLUTION

Accepted Solutions


Re: étiquettes dans un graphique

I think the problem is that the setting for decimal points (it's 0 in this case) do not work in the custom label format. My workaround is to go full width (12) and round the value up to the preferred number of decimals.

 

Graph Builder(
	Variables( X( :Xcolumn ), Y( :YColumn ) ), //Replace with your columns
	Elements(
		Bar(X,Y,
			Label( "Label by Value" ),
			Label Format(
				"Custom",
				Formula( If( value > 1500, Round( value, 2 ), " " ) ), //here you can set your formula and Round the value to any number of decimal points
				12, // full width
				0
			)
		)
	)
);

 

 

I have also attached an example table with the script included. I hope that solves the issue.

View solution in original post

5 REPLIES 5


Re: étiquettes dans un graphique

Hi Françoise, 

A fast solution would be to change the format of the label. Either by clicking on the Label format on the Graph Builder (see attached image) and adding the formula that works for you or do the same using JSL. 

Graph Builder(
	Variables( X( :Xcolumn ), Y( :Ycolumn ) ), // Replace with your Columns
	Elements(
        Bar( X, Y,
			Label( "Label by Value" ),
			Label Format( "Custom", Formula( If( value > 17.5, value, " " ) ), 4, 0 ) // Here you can set your formula to change the label format
		)
	)
);

Another approach could be to create an extra column in your data table (:Label Col) and add this as well to the graph. 

I hope that helps.

Best,
Spyros

 

 

hogi
Level XII


Re: étiquettes dans un graphique

Another Trick:
For lines, you can add labels and select which values will be displayed:

hogi_1-1737587953908.png

 

Together with the label, there will be the line:

hogi_2-1737587990032.png


one option to hide it:
adjust the color of the label (e.g. black) and use white for the line:

hogi_3-1737588060722.png

 

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	Variables( X( :sex ), X( :name, Position( 1 ) ), Y( :height ) ),
	Elements(
		Line( X( 1 ), X( 2 ), Y, Legend( 1 ), Interval Style( "Arrow" ) ),
		Bar( X( 1 ), X( 2 ), Y )
	),
	SendToReport(
		Dispatch( {}, "400", ScaleBox,
			{Legend Model(
				1,
				Properties(
					0,
					{Line Color( 2 ),
					Line Label Properties(
						{Max Value Label( 1 ), Label Color( "Black" ), Width( 9 )}
					)}
				)
			)}
		)
	)
);

 

Françoise
Level V


Re: étiquettes dans un graphique

hi,

 

thanks Spyros and Hogi for your answers.

 

but it's weird: when I use the spyros solution, the labels do not have the same format in the graph; see script copy and chart.

 

best regardsCapture 5.PNGCapture6.PNG

 


Re: étiquettes dans un graphique

I think the problem is that the setting for decimal points (it's 0 in this case) do not work in the custom label format. My workaround is to go full width (12) and round the value up to the preferred number of decimals.

 

Graph Builder(
	Variables( X( :Xcolumn ), Y( :YColumn ) ), //Replace with your columns
	Elements(
		Bar(X,Y,
			Label( "Label by Value" ),
			Label Format(
				"Custom",
				Formula( If( value > 1500, Round( value, 2 ), " " ) ), //here you can set your formula and Round the value to any number of decimal points
				12, // full width
				0
			)
		)
	)
);

 

 

I have also attached an example table with the script included. I hope that solves the issue.

Françoise
Level V


Re: étiquettes dans un graphique

Hi,

 

it's OK.

thanks !Capture7.PNG