How to access Data Points of a LineSeries

2 posts, 1 answers
  1. Shantimohan
    Shantimohan avatar
    42 posts
    Member since:
    Jul 2012

    Posted 24 Oct 2012 Link to this post

    Here is my XAML defining the use of RAD Chart control.
    <telerikChart:RadCartesianChart Grid.Row="2"
                                    x:Name="rccOverview"
                                    Margin="12,0,0,0"
                                    Palette="Warm">
        <telerikChart:RadCartesianChart.Behaviors>
            <telerikChart:ChartPanAndZoomBehavior HandleDoubleTap="False"
                                                  PanMode="None"
                                                  ZoomMode="None" />
        </telerikChart:RadCartesianChart.Behaviors>
     
        <telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:DateTimeCategoricalAxis LineStroke="{StaticResource PhoneDisabledBrush}"
                                                  LineThickness="2"
                                                  LabelFitMode="Rotate"
                                                  LabelRotationAngle="325"
                                                  LabelFormat="hh:mm"
                                                  DateTimeComponent="TimeOfDay"
                                                  FontSize="16"
                                                  PlotMode="OnTicks"
                                                  MajorTickInterval="2" />
        </telerikChart:RadCartesianChart.HorizontalAxis>
     
        <telerikChart:RadCartesianChart.VerticalAxis>
            <telerikChart:LinearAxis LineStroke="{StaticResource PhoneDisabledBrush}"
                                     LineThickness="2" />
        </telerikChart:RadCartesianChart.VerticalAxis>
     
        <telerikChart:RadCartesianChart.Grid>
            <telerikChart:CartesianChartGrid MajorLinesVisibility="XY"
                                             MajorXLineDashArray="5, 5"
                                             MajorYLineDashArray="5, 5">
                <telerikChart:CartesianChartGrid.MajorXLineStyle>
                    <Style TargetType="Line">
                        <Setter Property="Shape.Stroke"
                                Value="Gray" />
                    </Style>
                </telerikChart:CartesianChartGrid.MajorXLineStyle>
                <telerikChart:CartesianChartGrid.MajorYLineStyle>
                    <Style TargetType="Line">
                        <Setter Property="Shape.Stroke"
                                Value="Gray" />
                    </Style>
                </telerikChart:CartesianChartGrid.MajorYLineStyle>
            </telerikChart:CartesianChartGrid>
        </telerikChart:RadCartesianChart.Grid>
     
        <telerikChart:LineSeries>
            <telerikChart:LineSeries.PointTemplate>
                <DataTemplate>
                    <Ellipse Fill="White"
                             Height="10"
                             Width="10" />
                </DataTemplate>
            </telerikChart:LineSeries.PointTemplate>
     
            <telerikCharting:CategoricalDataPoint Category="9:30"
                                                  Value="50" />
            <telerikCharting:CategoricalDataPoint Category="9:45"
                                                  Value="50" />
            <telerikCharting:CategoricalDataPoint Category="10:00"
                                                  Value="80" />
            <telerikCharting:CategoricalDataPoint Category="10:15"
                                                  Value="80" />
            <telerikCharting:CategoricalDataPoint Category="10:30"
                                                  Value="90" />
            <telerikCharting:CategoricalDataPoint Category="10:45"
                                                  Value="80" />
            <telerikCharting:CategoricalDataPoint Category="11:00"
                                                  Value="120" />
            <telerikCharting:CategoricalDataPoint Category="11:15"
                                                  Value="120" />
            <telerikCharting:CategoricalDataPoint Category="11:30"
                                                  Value="110" />
            <telerikCharting:CategoricalDataPoint Category="11:45"
                                                  Value="120" />
            <telerikCharting:CategoricalDataPoint Category="12:00"
                                                  Value="130" />
            <telerikCharting:CategoricalDataPoint Category="12:15"
                                                  Value="130" />
            <telerikCharting:CategoricalDataPoint Category="12:30"
                                                  Value="92" />
            <telerikCharting:CategoricalDataPoint Category="12:45"
                                                  Value="130" />
            <telerikCharting:CategoricalDataPoint Category="13:00" />
            <telerikCharting:CategoricalDataPoint Category="13:15" />
            <telerikCharting:CategoricalDataPoint Category="13:30" />
            <telerikCharting:CategoricalDataPoint Category="13:45" />
            <telerikCharting:CategoricalDataPoint Category="14:00" />
            <telerikCharting:CategoricalDataPoint Category="14:15" />
            <telerikCharting:CategoricalDataPoint Category="14:30" />
            <telerikCharting:CategoricalDataPoint Category="14:45" />
            <telerikCharting:CategoricalDataPoint Category="15:00" />
            <telerikCharting:CategoricalDataPoint Category="15:15" />
            <telerikCharting:CategoricalDataPoint Category="15:30" />
            <telerikCharting:CategoricalDataPoint Category="15:45" />
            <telerikCharting:CategoricalDataPoint Category="16:00" />
        </telerikChart:LineSeries>
    </telerikChart:RadCartesianChart>

    I could define the CategoricalDataPoint in the xaml. But I am not able to access it from code. OK, I have put them in xaml for checking how it appears in the display. Now, I want to clear it and add points from retaltime data. How to go about it?
  2. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 25 Oct 2012 Link to this post

    Hi Shantimohan,

    Thanks for writing.
    You can populate the chart with data at run-time via the ItemsSource property of the series. If you set the property to an instance of ObservableCollection the chart will update itself when the data in the collection changes.

    You don't see the DataPoints property because it is declared in the LineSeries class. The Series property returns references of the base CartesianSeries type. You simply need to cast your series object to LineSeries in order to have access to the DataPoints property.
    I hope this is helpful.

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top