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

Line Annotation not showing up without matching data point

3 Answers 177 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Bkerby
Top achievements
Rank 1
Bkerby asked on 21 Jun 2013, 08:15 PM
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?



<telerik:CartesianGridLineAnnotation 
          Axis="{Binding ElementName=hAxis}"
          Value="{Binding Path=BreakEvenPoint}" Label="{Binding BreakEvenPointDesc}"
          StrokeThickness="2" Stroke="Gray" Style="{StaticResource DashedGridLineStyle}" >
</telerik:CartesianGridLineAnnotation>

3 Answers, 1 is accepted

Sort by
0
Bkerby
Top achievements
Rank 1
answered on 24 Jun 2013, 03:26 PM
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:RadCartesianChart.Behaviors>
                        <telerik:ChartTrackBallBehavior ShowTrackInfo="True"
                                           ShowIntersectionPoints="True"
                                           TrackInfoUpdated="ChartTrackBallBehavior_TrackInfoUpdated"/>
                    </telerik:RadCartesianChart.Behaviors>
 
                    <telerik:RadCartesianChart.Series>
                        <telerik:LineSeries ValueBinding="ValueY" CategoryBinding="ValueX" ItemsSource="{Binding ElementName=ChartDs}"
                             StrokeThickness="6" ClipToPlotArea="False" >
 
                            <telerik:LineSeries.PointTemplate>
                                <DataTemplate>
                                    <Ellipse Height="6" Width="6" 
                                     Fill="{Binding ElementName=chart, Path=Palette.GlobalEntries[0].Fill}"/>
                                </DataTemplate>
                            </telerik:LineSeries.PointTemplate>
 
                        </telerik:LineSeries>
 
                    </telerik:RadCartesianChart.Series>
 
                    <telerik:RadCartesianChart.HorizontalAxis>
                        <telerik:CategoricalAxis x:Name="hAxis" Title="Stock Price at Expiration" PlotMode="OnTicksPadded" 
                                              ElementBrush="{Binding ElementName=chart, Path=Palette.GlobalEntries[2].Fill}" LabelFormat="C3"
                                              />
                    </telerik:RadCartesianChart.HorizontalAxis>
 
                    <!--<telerik:RadCartesianChart.HorizontalAxis>
                        <telerik:LinearAxis x:Name="hAxis" Title="Stock Price at Expiration" 
                                              ElementBrush="{Binding ElementName=chart, Path=Palette.GlobalEntries[2].Fill}" LabelFormat="C"
                                              />
                    </telerik:RadCartesianChart.HorizontalAxis>-->
 
                    <telerik:RadCartesianChart.VerticalAxis>
                        <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:RadCartesianChart.VerticalAxis>
 
                    <telerik:RadCartesianChart.Grid>
                        <telerik:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y" />
                    </telerik:RadCartesianChart.Grid>
 
                    <telerik:RadCartesianChart.Annotations>
 
                        <telerik:CartesianGridLineAnnotation x:Name="annotation1"
                                                     Axis="{Binding ElementName=hAxis}"
                                                     Value="{Binding MaxGain}" Label="{Binding MaxGainDesc}"
                                                     StrokeThickness="2" Stroke="Gray" Style="{StaticResource DashedGridLineStyle}" >
                            <telerik:CartesianGridLineAnnotation.LabelDefinition>
                                <telerik:ChartAnnotationLabelDefinition Location="Right" Template="{StaticResource annotationTemplate2}">
 
                                </telerik:ChartAnnotationLabelDefinition>
                            </telerik:CartesianGridLineAnnotation.LabelDefinition>
                        </telerik:CartesianGridLineAnnotation>
                    </telerik:RadCartesianChart.Annotations>
 
                </telerik:RadCartesianChart>
0
Bkerby
Top achievements
Rank 1
answered on 24 Jun 2013, 04:33 PM
0
Rosko
Telerik team
answered on 26 Jun 2013, 12:16 PM
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.

Regards,
Rosko
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
Tags
ChartView
Asked by
Bkerby
Top achievements
Rank 1
Answers by
Bkerby
Top achievements
Rank 1
Rosko
Telerik team
Share this question
or