Overlapping labels question

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
cwodarczyk82
Posts: 43
Joined: Mon Oct 19, 2015 2:50 am

Overlapping labels question

Post by cwodarczyk82 » Fri Nov 13, 2015 3:54 pm

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...

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Overlapping labels question

Post by ArctionPasi » Fri Nov 13, 2015 7:29 pm

Unfortunately there is no such feature for SeriesEventMarkers.
LightningChart Support Team, PT

cwodarczyk82
Posts: 43
Joined: Mon Oct 19, 2015 2:50 am

Re: Overlapping labels question

Post by cwodarczyk82 » Fri Nov 13, 2015 8:30 pm

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

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Overlapping labels question

Post by ArctionPasi » Fri Nov 13, 2015 11:25 pm

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.
LightningChart Support Team, PT

Post Reply