RadCartesianChart Dynamic Series

2 posts, 0 answers
  1. crazy05
    crazy05 avatar
    72 posts
    Member since:
    Sep 2014

    Posted 11 May Link to this post

    Hello,

    I want to display multiple scatter line series dynamically from View Model. Right now, I am displaying succesfully using the below code but my requirement is not to use ScatterLineSeries multiple times and give it from View Model. I tried series provider but it is not giving anything. Is there any example for this ?

    I don't know how many scatterlineseries I need and it is dynamic. How can I do this ?

     

    <telerik:RadCartesianChart x:Name="Chart">
                <telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:LinearAxis Maximum="{Binding Max}" Minimum="0" Title="Generation" TickThickness="0">
                    </telerik:LinearAxis>
                </telerik:RadCartesianChart.HorizontalAxis>

                <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis Maximum="{Binding QMax}"  Minimum="{Binding QMin}" Title="Q (Max/Min)" TickThickness="0">
                    </telerik:LinearAxis>
                </telerik:RadCartesianChart.VerticalAxis>

                <telerik:RadCartesianChart.Annotations>
                    <telerik:CartesianGridLineAnnotation Axis="{Binding VerticalAxis, ElementName=DCurverChart}" Value="0" ></telerik:CartesianGridLineAnnotation>
                </telerik:RadCartesianChart.Annotations>

                <telerik:RadCartesianChart.Series>
                    <telerik:ScatterLineSeries ItemsSource="{Binding MaxDummyDataPoints}" XValueBinding="XValue" YValueBinding="YValue" Stroke="SaddleBrown">
                        <telerik:ScatterLineSeries.PointTemplate>
                            <DataTemplate>
                                <Ellipse Fill="Red" Width="5" Height="5" />
                            </DataTemplate>
                        </telerik:ScatterLineSeries.PointTemplate>
                    </telerik:ScatterLineSeries>
                    <telerik:ScatterLineSeries ItemsSource="{Binding MinDummyDataPoints}" XValueBinding="XValue" YValueBinding="YValue" Stroke="SaddleBrown" >
                        <telerik:ScatterLineSeries.PointTemplate>
                            <DataTemplate>
                                <Ellipse Fill="Red" Width="5" Height="5" />
                            </DataTemplate>
                        </telerik:ScatterLineSeries.PointTemplate>
                    </telerik:ScatterLineSeries>
                    <telerik:ScatterLineSeries ItemsSource="{Binding DataPoints}" XValueBinding="XValue" YValueBinding="YValue">
                        <telerik:ScatterLineSeries.PointTemplate>
                            <DataTemplate>
                                <Ellipse Fill="Red" Width="5" Height="5" />
                            </DataTemplate>
                        </telerik:ScatterLineSeries.PointTemplate>
                    </telerik:ScatterLineSeries>
                </telerik:RadCartesianChart.Series>
            </telerik:RadCartesianChart>

  2. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 12 May Link to this post

    Hi Ram,

    When it comes to a scenario with dynamic number of series you can use the chart's SeriesProvider. You can find couple SDK examples demonstrating this feature in our GitHub repository. They are located under the following folders in the repo.
    I want to make a small note about the scenario where the implicit styles theming mechanism (NoXaml binaries) is used. In this case, if you are setting a custom style to the Style property of the chart's series descriptor you will need to base it on the default style of the series which it targets. Otherwise, the custom style will override the default one completely, including its ControlTemplate, and no data points will be displayed. For example:
    <telerik:CategoricalSeriesDescriptor.Style>
        <Style TargetType="telerik:BarSeries" BasedOn="{StaticResource BarSeriesStyle}" />
    </telerik:CategoricalSeriesDescriptor.Style>
    This rule applies in all cases where implicit styles with a custom style are used.

    Regards,
    Martin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top