- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
labels in a chart
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
This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: étiquettes dans un graphique
Another Trick:
For lines, you can add labels and select which values will be displayed:
Together with the label, there will be the line:
one option to hide it:
adjust the color of the label (e.g. black) and use white for the line:
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 )}
)}
)
)}
)
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: étiquettes dans un graphique
Hi,
it's OK.
thanks !