[RadChartView] PieTwoLabelColumnsStrategy - DistanceBetweenLabels not working properly

1 Answer 25 Views
ChartView
Jérôme
Top achievements
Rank 1
Iron
Iron
Iron
Jérôme asked on 10 Nov 2023, 02:02 PM

Hi,

I'm using Telerik for Winforms 2023.3.1010 on .NET 7.

While trying to configure the position of my label position using PieTwoLabelColumnsStrategy, only the first label seems to be working with DistanceBetweenLabels property.

 

 PieTwoLabelColumnsStrategy strategy = new PieTwoLabelColumnsStrategy()
 {
     DistanceBetweenLabels = 50,
     DistanceToLabel = -100
 };

 SmartLabelsController smartLabelsController = new SmartLabelsController
 {
     Strategy = strategy
 };

 radChartView.Controllers.Add(smartLabelsController);
 radChartView.ShowSmartLabels = true;

Here is how I'm filling the chart:


   radChartView.AreaType = ChartAreaType.Pie;
   radChartView.Series.Clear();

   DonutSeries donut = new DonutSeries
   {
       ShowLabels = true,
       LabelMode = PieLabelModes.Horizontal,
       DrawLinesToLabels = true,
       SyncLinesToLabelsColor = true,
       NumberOfColors = categoryCount
   };

   foreach (var v in totals.OrderByDescending(s => s.Statut))
   {
       PieDataPoint point = new PieDataPoint(v.Nombre, v.Statut)
       {
           Label = $"{v.Percentage}% {v.Statut}"
       };

       donut.DataPoints.Add(point);
   }

   radChartView.Series.Add(donut);
   radChartView.Area.View.Palette = KnownPalette.Metro;
   radChartView.SelectionMode = ChartSelectionMode.SingleDataPoint;
   radChartView.BackColor = Color.WhiteSmoke;

With small percentages, it doesn't work (except of the right bottom label)

With higher percentages it seems to be working :

The behavior is quite inconsistent.

Thank you for your help.

 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Nov 2023, 12:18 PM

Hello Jérôme,

Thank you for the provided details.

To test your case, I have created a sample project using the provided code snippets. So far I wasn't able to observe the described behavior. Could it be possible to modify my test project to reproduce this behavior and send it back to me so that I can debug it on my side and try to find a suitable solution? Also, in your post, you mentioned that "With higher percentages, it seems to be working". Can you elaborate more on what you mean by "higher percentages"? Do you mean that the labels are okay on higher DPI? If yes, what is the current resolution of them monitor when you start the application and what is the resolution when the labels are positioned correctly?

I am looking forward to your reply.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jérôme
Top achievements
Rank 1
Iron
Iron
Iron
commented on 14 Nov 2023, 03:50 PM | edited

Hi Dinko,

I'm able to reproduce my issue. I've adjusted your code, changing the databinding part.

With this code, the labels are not evenly spaced between them. I'm wondering if it's because of the very low percentages.

The more you increase DistanceBetweenLabels property, the more visible it becomes.

Thank you for your help.

Regards

Dinko | Tech Support Engineer
Telerik team
commented on 15 Nov 2023, 01:59 PM

I appreciate your effort in updating the project to reproduce the described behavior. I have examined this behavior and see what you mean here. When the smart labels strategy is set, it will target the labels that are overlapping. With this in hand, the value in the DistanceBetweenLabels property will be used for labels that overlap. It will not be used to set the distance between all labels. In this particular case, the orange label (United States) does not move which makes it static as it does not overlap with any other label. The distance between the next label (Spain) will vary depending on the height of the pie series. 

I have forwarded this behavior to the development team for further investigation. Upon brief discussion, we agree that this is more of a corner case. Basically, setting a big value to the DistanceBetweenLabels won't be valid as it will move the labels outside the chart area. Using a big value for this property with the combination of data points with very close values will lead to an undesirable visual result. My recommendation will be to set a value to the DistanceBetweenLabels which most fit your case. The labels in any case won't overlap, however, the value between the labels that are overlapping by default should not increase the height of the chart component.

I hope that my reply sheds some light on this behavior.

Jérôme
Top achievements
Rank 1
Iron
Iron
Iron
commented on 16 Nov 2023, 12:00 PM

Thank you for clarifying this component's behavior. Maybe the documentation of ChartView could be updated to explain the interest of DistanceBetweenLabels property when using a SmartLabelsController.

Regards

Dinko | Tech Support Engineer
Telerik team
commented on 16 Nov 2023, 01:06 PM

You have a point here. I have double-checked the documentation and indeed this property is not mentioned. I have logged an internal task to update the Smart labels help article and provide more information regarding the build strategies and their properties.

I have updated your Telerik Points for bringing this to our attention.

Jérôme
Top achievements
Rank 1
Iron
Iron
Iron
commented on 17 Nov 2023, 12:50 PM

Thank you !
Tags
ChartView
Asked by
Jérôme
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or