Smart labels
RadChartView provides a built-in mechanism for resolving labels overlapping with the SmartLabelsController. You can add the controller to the Controllers collection of RadChartView and it will optimize the arrangement of the labels in a way that there will be less overlaps.
Add Controller
Alternatively, you can leave RadChartView do this for you by setting the ShowSmartLabels property:
Set Property
Automatic label placement is one the most complex and time consuming operations in a chart that is NP-hard (http://en.wikipedia.org/wiki/NP-Hard). There is no universal solution for all chart types and there is no solution that can guarantee solution for 100% of the label collisions in every case.
Figure 1: Without Smart Labels
Figure 2: With Smart Labels
RadChartView’s SmartLabelsController uses strategies specific to different chart types to resolve label overlaps. Since label overlapping can be quite time consuming with more generalized methods, the more concrete a strategy is the better the performance that can be expected out of it. You do not need to be concerned with the strategy, RadChartView will choose the best of the built-in strategies to be used in your chart.
Figure 3: Without Smart Labels
Figure 4: With Smart Labels
Figure 5: Without Smart Labels
Figure 6: With Smart Labels
Custom labels strategy
In a specific scenario you may need to control the labels' position. For this purpose, create a derivative of the SmartLabelsStrategyBase class and override its CalculateLocations method. Then, you should use this custom logic in the SmartLabelsController. You can find below a sample code snippet demonstrating how you can position the labels in the top part of the chart:
Custom SmartLabelsStrategy
You must apply the custom SmartLabelsController to RadChartView:
Apply custom strategy
After the R3 2018 SP1 release, the custom strategy can be applied after setting the Strategy property of the control and after regsitering it with all compatible series:
Before | After |
---|---|
![]() |
![]() |