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

RadCartesianChart Dynamic Series

1 Answer 302 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
crazy05
Top achievements
Rank 1
crazy05 asked on 11 May 2016, 05:28 PM

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>

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 12 May 2016, 08:48 AM
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.
Tags
ChartView
Asked by
crazy05
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or