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

Dynamic PointSeries

5 Answers 125 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
VladB
Top achievements
Rank 1
VladB asked on 13 Nov 2016, 08:54 AM

Hi

I am trying to create a dynamic point series chart on DateTimeContinuousAxes but getting "No Series Added" message.

Here is the model classes I use:

01.public class SeriesModel{
02.        public ObservableCollection<DataPointModel> Items { get; set; }
03.}
04.public class DataPointModel {
05.        public DateTime Date { get; set; }
06.        public int NodeId { get; set; }
07.}
08. 
09.// In the MainWindow() constructor I create and populate Data collection
10.// with SeriesModel collections - one for each series.
11.ObservableCollection<SeriesModel> Data = new ObservableCollection<SeriesModel>();

 

Here is a fragment of XAML I use for creating a dynamic pointseries chart:

01.<telerik:RadCartesianChart.HorizontalAxis>
02.    <telerik:DateTimeContinuousAxis/>
03.</telerik:RadCartesianChart.HorizontalAxis>
04. 
05.<telerik:RadCartesianChart.SeriesProvider>
06.    <telerik:ChartSeriesProvider Source="{Binding Data}">
07.        <telerik:ChartSeriesProvider.SeriesDescriptors>
08.            <telerik:ChartSeriesDescriptor ItemsSourcePath="Items">
09.                <telerik:ChartSeriesDescriptor.Style>
10.                    <Style TargetType="telerik:PointSeries">
11.                        <Setter Property="CategoryBinding" Value="Date"/>
12.                        <Setter Property="ValueBinding"  Value="NodeId"/>
13.                    </Style>
14.                </telerik:ChartSeriesDescriptor.Style>
15.            </telerik:ChartSeriesDescriptor>
16.        </telerik:ChartSeriesProvider.SeriesDescriptors>
17.    </telerik:ChartSeriesProvider>
18.</telerik:RadCartesianChart.SeriesProvider>

 

Could you please help to find an error in this code?

Regards,

Vlad

5 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 15 Nov 2016, 09:28 AM
Hi Vlad,

Your set up seems correct. This is shot in the dark, but I guess you are using NoXaml dlls and the implicit theming mechanism. If so, keep in mind that each custom style targeting a control from the UI for WPF suite should be based on the default control style. In your case you will need to base the descriptor's style to the base PointSeriesStyle.
<telerik:ChartSeriesDescriptor.Style>
    <Style TargetType="telerik:PointSeries" BasedOn="{StaticResource PointSeriesStyle}">
        <Setter Property="CategoryBinding" Value="Date"/>
        <Setter Property="ValueBinding"  Value="NodeId"/>
    </Style>
</telerik:ChartSeriesDescriptor.Style>

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
VladB
Top achievements
Rank 1
answered on 20 Nov 2016, 04:07 AM

Hi Martin,

I don't do anything special about theming / NoXaml dlls - I simply created a default Telerik WPF project. Do I need to do anything special about that or is the default configuration is ok?

Adding BasedOn="{StaticResource PointSeriesStyle}" attribute to the Style tag didn't help - the result is the same.

 

0
Martin Ivanov
Telerik team
answered on 21 Nov 2016, 08:09 AM
Hello Vlad,

The BasedOn attribute is required only if you are using NoXaml dlls. Otherwise, you do not need it, and even you won't be able to get the styles by x:Key using the StaticResource keyword.

I noticed that the ObservableCollection<SeriesModel> called "Data" is defined as a field (it doesn't have a getter and/or setter). Also, it doesn't have a access modifier set (public, private, internal, etc.) which means by default is private. Note that the WPF binding system works with public properties. Double check if the Data collection is defined as a public property and see if the issue still appears.
public ObservableCollection<SeriesModel> Data { get; set; }
You can also check if the Data collection contains any SeriesModel objects.

Regards,
Martin
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
0
VladB
Top achievements
Rank 1
answered on 21 Nov 2016, 09:14 AM

Hi Martin,

Unfortunately, it didn't work. I declared Data as a public property of the MainWindow class and populated it with data in the MainWindow() constructor. The result is still the same - "No series added"

 

Regards,

Vlad

 

0
Martin Ivanov
Telerik team
answered on 21 Nov 2016, 09:35 AM
Hello Vlad,

I am afraid without your implementation I can't tell why the data points are not displayed. However, as the message states, it seems that the data source containing the series models is empty. You can try debugging the binding of the series provider Source property using an IValueConverter and see if the proper collection (Data) propagates to the provider. 

Regards,
Martin
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
ChartView
Asked by
VladB
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
VladB
Top achievements
Rank 1
Share this question
or