Force labels to ticks with certain values?

2 posts, 1 answers
  1. Clas Ericson
    Clas Ericson avatar
    31 posts
    Member since:
    Sep 2011

    Posted 15 May 2012 Link to this post

    I'm wondering if there's way to force the labels of an axis to ticks with certain values, for example force the labels to tick 1.0, 1.5, 2.0, 2.5 and so on?

    The chart where I want to use this has an linearaxis with pan and zoom enabled and if you zoom in and pan the labels can be positioned like 4.2, 4.7, 5.2, 5.7 and so on. If you pan a bit more they could be positioned as I want them to. It seems like it depends on the first visible value of the axis how the labels layed out.

    Below is the XAML for my chart.

    Regards, Clas Ericson

                Title="{Binding XAxisTitle}"
                LabelTemplate="{StaticResource labelTemplate}"
                LabelInterval="5" />
            <telerik:LinearAxis LabelFormat="P1" Title="{Binding YAxisTitle}" />
            <telerik:ChartPanAndZoomBehavior PanMode="Both" ZoomMode="Both" />
            <telerik:CartesianChartGrid MajorLinesVisibility="Y"  />
        <chartView:ScatterPointSeries AllowSelect="False" ItemsSource="{Binding EmptySerie}"  XValueBinding="XValue" YValueBinding="YValue" /> 
  2. Answer
    Petar Marchev
    Petar Marchev avatar
    1029 posts

    Posted 18 May 2012 Link to this post

    Hello Clas,

    Unfortunately the ChartView does not currently expose such settings. I am not familiar with your scenario, but what I can suggest for you to try is to use a VisibiliryConverter - to hide all labels except the ones that contain 1.0, 1.5 and so on. You will need to adjust, or even remove, the MajorStep and LabelInterval settings.

    I have attached a project based on your code, in which I have added this converter. Let us know if it fits your scenario.

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top