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

Force labels to ticks with certain values?

1 Answer 114 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Clas Ericson
Top achievements
Rank 2
Clas Ericson asked on 15 May 2012, 10:35 AM
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>

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Marchev
Telerik team
answered on 18 May 2012, 10:22 AM
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 >>

Tags
ChartView
Asked by
Clas Ericson
Top achievements
Rank 2
Answers by
Petar Marchev
Telerik team
Share this question
or