Line Annotation not showing up without matching data point

4 posts, 0 answers
  1. Bkerby
    Bkerby avatar
    9 posts
    Member since:
    Apr 2012

    Posted 21 Jun 2013 Link to this post

    I need to be able to set my line annotation in between data points but if the x value on my annotation doesn't match an x value of a data point it does not show up.  
    Is there a way to do this without changing my x axis labels?

              Axis="{Binding ElementName=hAxis}"
              Value="{Binding Path=BreakEvenPoint}" Label="{Binding BreakEvenPointDesc}"
              StrokeThickness="2" Stroke="Gray" Style="{StaticResource DashedGridLineStyle}" >
  2. Bkerby
    Bkerby avatar
    9 posts
    Member since:
    Apr 2012

    Posted 24 Jun 2013 Link to this post

    Both axis are currencies and using a categorical axis for the x axis doesn't allow me to place a line annotation unless it lands on a data point. Here is the rest of my code, hopefully someone can help.  All of the online examples use date/time for the categorical axis while i need to use a currency.

    <telerik:ChartDataSource x:Name="ChartDs" ItemsSource="{Binding ChartData}"></telerik:ChartDataSource>
                    <telerik:RadCartesianChart Grid.Row="1" x:Name="chart" Palette="Arctic" ClipToBounds="False" >
                            <telerik:ChartTrackBallBehavior ShowTrackInfo="True"
                            <telerik:LineSeries ValueBinding="ValueY" CategoryBinding="ValueX" ItemsSource="{Binding ElementName=ChartDs}"
                                 StrokeThickness="6" ClipToPlotArea="False" >
                                        <Ellipse Height="6" Width="6" 
                                         Fill="{Binding ElementName=chart, Path=Palette.GlobalEntries[0].Fill}"/>
                            <telerik:CategoricalAxis x:Name="hAxis" Title="Stock Price at Expiration" PlotMode="OnTicksPadded" 
                                                  ElementBrush="{Binding ElementName=chart, Path=Palette.GlobalEntries[2].Fill}" LabelFormat="C3"
                            <telerik:LinearAxis x:Name="hAxis" Title="Stock Price at Expiration" 
                                                  ElementBrush="{Binding ElementName=chart, Path=Palette.GlobalEntries[2].Fill}" LabelFormat="C"
                            <telerik:LinearAxis Title="Profit or Loss" x:Name="vAxis" RangeExtendDirection="Both"
                                                  ElementBrush="{Binding ElementName=chart, Path=Palette.GlobalEntries[2].Fill}" 
                                                  HorizontalLocation="Left" LabelFormat="C" />
                            <telerik:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y" />
                            <telerik:CartesianGridLineAnnotation x:Name="annotation1"
                                                         Axis="{Binding ElementName=hAxis}"
                                                         Value="{Binding MaxGain}" Label="{Binding MaxGainDesc}"
                                                         StrokeThickness="2" Stroke="Gray" Style="{StaticResource DashedGridLineStyle}" >
                                    <telerik:ChartAnnotationLabelDefinition Location="Right" Template="{StaticResource annotationTemplate2}">
  3. Bkerby
    Bkerby avatar
    9 posts
    Member since:
    Apr 2012
  4. Rosko
    Rosko avatar
    137 posts

    Posted 26 Jun 2013 Link to this post

    Hello Bkerby,

    I think you need a little explanation on the scenario.

    As I understood, you are using on both axes currencies, i.e. you are putting continuous numerical values. Thus, you do not need categories, since they are generated per item in the ItemsSource.

    When using a categorical axis, you might have categories "Cat1" and "Cat3" in the ItemsSource, but this does not mean you have "Cat2" on the axis. But if you are using a linear axis, you will have all values between, let's say, 1 and 2 generated, i.e. 1.002, 1.0021 and so on. Consequently, you will be able to put an annotation on a specific value of your preference. Otherwise, you will need an already existing category, which, for instance, in your scenario is missing.

    I hope this brings light into the behavior of RadChartView.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top