Hello, this is more of an advice question than anything. I have a graph that is setup as segments, (screenshot on the bottom). As you can see, the Titles for the Y axis can get way longer than they should be, and it reduces redability.
I'd liek to do one of three things:
A) Insert newlines in the title text if the title text gets longer than the height of the segment
B) Cut the text off if it gets arbitrarely longer than X pixels, where X is some constant
C) Cut the text off it gets longer than the height of the segment.
Is there any way to accomplish any of these.
Right now whats coming to my mind is an 'updatetitles' method, which is called on chartresize that will call measurestring on text, compare the width to the segment width and then modify the chart title if it seems too long.
Is there a better approach?
Thanks.
Y-Axis labelling - how to manage the size better
Moderator: Queue Moderators
-
- Posts: 183
- Joined: Tue Mar 18, 2014 2:55 pm
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Y-Axis labelling - how to manage the size better
Hi Greg,
you pretty much have figured out how to do it.
You may want to try also with chart.BeforeRendering event handler, pretty much like this:
you pretty much have figured out how to do it.
You may want to try also with chart.BeforeRendering event handler, pretty much like this:
Code: Select all
void _chart_BeforeRendering(object sender, BeforeRenderingEventArgs e)
{
GraphSegmentInfo gsi = _chart.ViewXY.GetGraphSegmentInfo();
for (int seg = 0; seg < gsi.SegmentCount; seg++)
{
foreach (AxisY yAxis in _chart.ViewXY.GetYAxesInSegment(seg))
{
if ((gsi.SegmentBottoms[seg] - gsi.SegmentTops[seg]) < _chart.MeasureText("AAAA BBBB CCCC DDDD EEEE FFFF", yAxis.Title.Font).X)
{
yAxis.Title.Text = "AAAA BBBB CCCC\nDDDD EEEE FFFF";
}
else
yAxis.Title.Text = "AAAA BBBB CCCC DDDD EEEE FFFF";
}
}
}
LightningChart Support Team, PT
-
- Posts: 183
- Joined: Tue Mar 18, 2014 2:55 pm
Re: Y-Axis labelling - how to manage the size better
Thanks pasi, i'll give this a try
-
- Posts: 183
- Joined: Tue Mar 18, 2014 2:55 pm
Re: Y-Axis labelling - how to manage the size better
Solution worked great, thanks. Only small hiccup i had was whether i had segements 'enabled' or not, to get the allowable width.
Now if I can just get someone to fix all of my automatic margin issues for me
Now if I can just get someone to fix all of my automatic margin issues for me