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

Annotation on CategoricalAxis

2 Answers 52 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Bárbara
Top achievements
Rank 1
Bárbara asked on 19 Nov 2015, 11:29 AM

<telerik:RadCartesianChart x:Name="cartesianChart">
    <telerik:RadCartesianChart.Annotations>
  <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=verticalAxis}" 
Value="6"
Stroke="Red"
StrokeThickness="1"/>
<telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=horizontalAxis}" 
Value="2.8"
Stroke="Blue"
StrokeThickness="1"/>
</telerik:RadCartesianChart.Annotations>

<telerik:RadCartesianChart.Series>
<telerik:ScatterPointSeries>
<telerik:ScatterPointSeries.DataPoints>
<telerik:ScatterDataPoint XValue="1" YValue="5"/>
<telerik:ScatterDataPoint XValue="3" YValue="2"/>
<telerik:ScatterDataPoint XValue="4" YValue="7"/>
</telerik:ScatterPointSeries.DataPoints>
</telerik:ScatterPointSeries>
</telerik:RadCartesianChart.Series>

<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis x:Name="verticalAxis"/>
</telerik:RadCartesianChart.VerticalAxis>

<telerik:RadCartesianChart.HorizontalAxis>
<telerik:LinearAxis x:Name="horizontalAxis"/>
</telerik:RadCartesianChart.HorizontalAxis>
</telerik:RadCartesianChart>

</telerik:RadCartesianChart>

2 Answers, 1 is accepted

Sort by
0
Bárbara
Top achievements
Rank 1
answered on 19 Nov 2015, 11:49 AM

*****DESCONSIDER PREVIOUS POST********

I'm trying to add CartesianGridLineAnnotation and I did it through Telerik examples, but when I try to use LineSeries the Annotations on the HorizontalAxis don't show up.
I'm guessing the problem is that on the horizontal we use CategoricalAxis, but then when I put both vertical and horizontal axis to be LinearAxis the serie itself doesn't show up.

 

 ********SCATTER POINT****************
<telerik:RadCartesianChart x:Name="cartesianChart">
    <telerik:RadCartesianChart.Annotations>
       <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=verticalAxis}" 
        Value="6"
        Stroke="Red"
        StrokeThickness="1"/>
       <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=horizontalAxis}" 
      Value="2.8"
      Stroke="Blue"
      StrokeThickness="1"/>
</telerik:RadCartesianChart.Annotations>

<telerik:RadCartesianChart.Series>
<telerik:ScatterPointSeries>
<telerik:ScatterPointSeries.DataPoints>
<telerik:ScatterDataPoint XValue="1" YValue="5"/>
<telerik:ScatterDataPoint XValue="3" YValue="2"/>
<telerik:ScatterDataPoint XValue="4" YValue="7"/>
</telerik:ScatterPointSeries.DataPoints>
</telerik:ScatterPointSeries>
</telerik:RadCartesianChart.Series>

<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis x:Name="verticalAxis"/>
</telerik:RadCartesianChart.VerticalAxis>

<telerik:RadCartesianChart.HorizontalAxis>
<telerik:LinearAxis x:Name="horizontalAxis"/>
</telerik:RadCartesianChart.HorizontalAxis>
</telerik:RadCartesianChart>
</telerik:RadCartesianChart>

 ******************LINE SERIES***************************
<telerik:RadCartesianChart x:Name="cartesianChart">
    <telerik:RadCartesianChart.Annotations>
       <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=verticalAxis}" 
        Value="6"
        Stroke="Red"
        StrokeThickness="1"/>
       <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=horizontalAxis}" 
      Value="2.8"
      Stroke="Blue"
      StrokeThickness="1"/>
</telerik:RadCartesianChart.Annotations>
<telerik:RadCartesianChart.Series>
                <telerik:LineSeries>
                    <telerik:LineSeries.DataPoints>
                        <telerik:CategoricalDataPoint Category="1" Value="5"/>
                        <telerik:CategoricalDataPoint Category="3" Value="2"/>
                        <telerik:CategoricalDataPoint Category="4" Value="7"/>
                    </telerik:LineSeries.DataPoints>
                </telerik:LineSeries>
            </telerik:RadCartesianChart.Series>

            <telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis x:Name="verticalAxis"/>
</telerik:RadCartesianChart.VerticalAxis>

<telerik:RadCartesianChart.HorizontalAxis>
<telerik:CategoricalAxis x:Name="horizontalAxis"/>
</telerik:RadCartesianChart.HorizontalAxis>
</telerik:RadCartesianChart>

0
Milena
Telerik team
answered on 23 Nov 2015, 11:29 AM
Hello B├írbara,

Thank you for the code-snippets provided. 

As the categorical axis displays a range of categories, the Value of the Annotation should be a category. In the example you sent, you could change the value of the second annotation to 1, 3 or 4 (one of the category in the series):
<telerik:RadCartesianChart.Annotations>
    <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=verticalAxis}"
    Value="6"
    Stroke="Red"
    StrokeThickness="1"/>
    <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=horizontalAxis}"
    Value="3"
    Stroke="Blue"
    StrokeThickness="1"/>
</telerik:RadCartesianChart.Annotations>

I hope this information helps.

Regards,
Milena
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Bárbara
Top achievements
Rank 1
Answers by
Bárbara
Top achievements
Rank 1
Milena
Telerik team
Share this question
or