This is a migrated thread and some comments may be shown as answers.

SmartLabelsStrategy: limit no. of labels to display

3 Answers 107 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Nitin Nitin
Top achievements
Rank 1
Nitin Nitin asked on 23 Nov 2013, 02:18 PM
Hi,

Using latest Telerik Q3 2013 dlls, I have implemented smart labels as followed

<telerik:RadCartesianChart.SmartLabelsStrategy>
            <telerik:ChartSmartLabelsStrategy />
        </telerik:RadCartesianChart.SmartLabelsStrategy>
 
and
 
 
        <telerik:RadCartesianChart.SeriesProvider>
            <telerik:ChartSeriesProvider Source="{Binding SeriesCollection,Mode=TwoWay}">
                <telerik:ChartSeriesProvider.SeriesDescriptors>
                    <telerik:CategoricalSeriesDescriptor ItemsSourcePath="Data" ValuePath="LineSeriesChartValue" CategoryPath="LineSeriesChartCategory">
                        <telerik:CategoricalSeriesDescriptor.Style>
                            <Style TargetType="telerik:LineSeries">
                                <Setter Property="CombineMode" Value="Cluster" />
                                <Setter Property="TrackBallInfoTemplate" Value="{Binding TrackballInfoTemplate, Mode=TwoWay}" />
                                <Setter Property="Stroke" Value="{Binding SeriesStroke, Mode=TwoWay}" />
                                <Setter Property="Tag" Value="{Binding SeriesName, Mode=TwoWay}" />
                                <Setter Property="VerticalAxis" Value="{Binding VerticalAxis, Mode=TwoWay}" />
                                <Setter Property="ShowLabels" Value="{Binding IsLabelEnabled, Mode=TwoWay}
"
/>
                            </Style>
                        </telerik:CategoricalSeriesDescriptor.Style>
                    </telerik:CategoricalSeriesDescriptor>
                </telerik:ChartSeriesProvider.SeriesDescriptors>
            </telerik:ChartSeriesProvider>
             
        </telerik:RadCartesianChart.SeriesProvider>

and in the viewmodel 

private void ShowMarkers(bool IsShowLabelEnabled)
{
   if(IsShowLabelEnabled)
   {
      IsLabelEnabled = true;
      xRadCartesianChart.SmartLabelsStrategy = new ChartSmartLabelsStrategy();
   }
}

1. The chart shows per minute datapoints starting from 6am to 6pm
2. The chart height and width is around 250 * 250.

Since the chart is smaller in height and width as per the design & as the series contains many datapoints, the labels are overlapping.

As the smart labels are not readable (PFA), we want a functionality where we can calculate the number of labels to be displayed depending upon the data points and zoomed/viewable chart

For eg: for a chart with 1000 datapoints should show only equally distanced 10 data point smart labels.

Please provide me a way to achieve the solution to the above requirement.

Thanks,
Nitin 






3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 27 Nov 2013, 09:39 AM
Hello Nitin,

You can use LabelInterval property of the axis. Setting it to 5 for example will show every fifth label. Here is some code:
<telerik:CategoricalAxis LabelInterval="10" />

So for your scenario you can set it to 100.

Regards,
Yavor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Nitin Nitin
Top achievements
Rank 1
answered on 30 Nov 2013, 11:18 AM
Sorry it didnot fixed my problem.
Setting the LabelInterval property changed my y-axis labels.

I was looking for controlling the smartlabels count in the chart. (check attachment)

0
Yavor
Telerik team
answered on 02 Dec 2013, 09:59 AM
Hi Nitin,

Smart labels are useful in scenarios where you have reasonable amount of labels and you want to adjust their positions to look better. In your scenarios you have a lot of labels in small area. Smart labels will try to adjust accordingly, but still it will be hard to tell which label corresponds to which point.

In your scenario I suggest that you use custom annotations that show only the labels that you want. This way you can have any number of labels that you want.

Regards,
Yavor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Nitin Nitin
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Nitin Nitin
Top achievements
Rank 1
Share this question
or