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

    Hi,
    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

    <telerik:RadCartesianChart           
        x:Name="chart"
        Grid.Row="2"
        Grid.ColumnSpan="2"
        HorizontalAlignment="Stretch"
        VerticalAlignment="Stretch"
        Margin="0,0,0,0">
        <telerik:RadCartesianChart.HorizontalAxis>
            <telerik:LinearAxis
                LastLabelVisibility="Visible"
                Title="{Binding XAxisTitle}"
                LabelTemplate="{StaticResource labelTemplate}"
                LabelFormat="#.#"
                MajorStep="5"
                LabelInterval="5" />
        </telerik:RadCartesianChart.HorizontalAxis>
        <telerik:RadCartesianChart.VerticalAxis>
            <telerik:LinearAxis LabelFormat="P1" Title="{Binding YAxisTitle}" />
        </telerik:RadCartesianChart.VerticalAxis>
        <telerik:RadCartesianChart.Behaviors>
            <telerik:ChartPanAndZoomBehavior PanMode="Both" ZoomMode="Both" />
        </telerik:RadCartesianChart.Behaviors>
        <telerik:RadCartesianChart.Grid>
            <telerik:CartesianChartGrid MajorLinesVisibility="Y"  />
        </telerik:RadCartesianChart.Grid>           
        <chartView:ScatterPointSeries AllowSelect="False" ItemsSource="{Binding EmptySerie}"  XValueBinding="XValue" YValueBinding="YValue" /> 
    </telerik:RadCartesianChart>
  2. Answer
    Petar Marchev
    Admin
    Petar Marchev avatar
    968 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 >>

  3. DevCraft banner
Back to Top