Annotation on CategoricalAxis

3 posts, 0 answers
  1. Bárbara
    Bárbara avatar
    16 posts
    Member since:
    Nov 2015

    Posted 19 Nov 2015 Link to this post

    <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. Bárbara
    Bárbara avatar
    16 posts
    Member since:
    Nov 2015

    Posted 19 Nov 2015 Link to this post

    *****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>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Milena
    Admin
    Milena avatar
    201 posts

    Posted 23 Nov 2015 Link to this post

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