Overlapping labels question
Moderator: Queue Moderators
-
- Posts: 43
- Joined: Mon Oct 19, 2015 2:50 am
Overlapping labels question
Just to shoot out a quick question in case I missed it in the documentation someplace... is there a similar feature as there is for WinForms SeriesCollection where you can enable a SmartLabelController which will prevent series event markers from overlapping? If not, that is ok, I am just making sure I didn't miss something...
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Overlapping labels question
Unfortunately there is no such feature for SeriesEventMarkers.
LightningChart Support Team, PT
-
- Posts: 43
- Joined: Mon Oct 19, 2015 2:50 am
Re: Overlapping labels question
Hi, Pasi:
Thanks for replying... is there a suggested post that you could direct me to that could get me started in the right direction of what properties, methods, etc I could use to best detect overlapping labels and write an algorithm to prevent this?
Thanks
Thanks for replying... is there a suggested post that you could direct me to that could get me started in the right direction of what properties, methods, etc I could use to best detect overlapping labels and write an algorithm to prevent this?
Thanks
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Overlapping labels question
To check if labels overlap, you can use chart.MeasureText method. Pass the marker's label font and its text, and you get its size in pixels.
Set marker.VerticalPosition = AtYValue, and marker.HorizontalPosition = AtXValue.
Set marker position as axis values in marker.XValue and marker.YValue properties.
Marker positions can be converted into screen coordinates with xAxis.ValueToCoord and yAxis.ValueToCoord methods. You will get the marker center location in pixels.
Marker labels has different alignment options. Label.VerticalAlign = Bottom makes the label appear beneath the marker symbol. Label.HorizontalAlign = Right shows it on the right side of it. Combined, in bottom right. Marker.Label.Distance sets the distance of the label in pixels, from the symbol.
So if the labels overlap, by changing the alignment options or Distance will help.
Set marker.VerticalPosition = AtYValue, and marker.HorizontalPosition = AtXValue.
Set marker position as axis values in marker.XValue and marker.YValue properties.
Marker positions can be converted into screen coordinates with xAxis.ValueToCoord and yAxis.ValueToCoord methods. You will get the marker center location in pixels.
Marker labels has different alignment options. Label.VerticalAlign = Bottom makes the label appear beneath the marker symbol. Label.HorizontalAlign = Right shows it on the right side of it. Combined, in bottom right. Marker.Label.Distance sets the distance of the label in pixels, from the symbol.
So if the labels overlap, by changing the alignment options or Distance will help.
LightningChart Support Team, PT