SmartLabelsStrategy: limit no. of labels to display

4 posts, 0 answers
  1. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 23 Nov 2013 Link to this post

    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 






  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 27 Nov 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 30 Nov 2013 Link to this post

    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)

  5. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 02 Dec 2013 Link to this post

    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 >>
Back to Top