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

How to create a dynamic number of series in a graph

1 Answer 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Spencer
Top achievements
Rank 1
Spencer asked on 22 Jan 2019, 08:37 PM

Hello,
I'm creating a report using something similar to the following classes:

public class Point
{
    public double X { get; set; }
    public double Y { get; set; }
}
 
public class Series
{
    public List<Point> Points { get; set; }
}
 
public class MultipleSeries
{
    public string Header { get; set; }
 
    //There could be any number of these
    public List<Series> Series { get; set; }
}
 
public class ManyMultipleSeries
{
    public List<MultipleSeries> ManySeries { get; set; }
}

 

Basically, the main report will bind to 'ManyMultipleSeries'. This class will have a list of 'MultipleSeries', which are bound to a sub report that contains the chart. The 'MultipleSeries' class could contain any number of 'Series' that need to be displayed in the chart. I could not find any way of creating a dynamic number of series like this in the docs. Thanks for any help.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 25 Jan 2019, 11:49 AM
Hi Spencer,

I noticed that you have opened a Support ticket on the same topic.
We have answered your questions and provided examples in the support thread. For the benefit of our community I will summarize our answers also here.

By setting the DataSource of nested data items through their parent DataSource, i.e. main Report->subreport->Graph you may assign the Fields.Series from MultipleSeries as DataSource of the Graph data item. However, the type of the items stored in Series collection should *not* be a collection to be resolved properly.
Generally, all simple type properties from the data source can be used directly in the report to show their values using expressions such as "= Fields.MyProperty". Complex objects can also be used by accessing their nested properties using the dot notation i.e. "= Fields.MyProperty.NestedProperty", etc.
Collection properties cannot be used directly and you need to bind them to a nested data item.
The solution in the specific case is MultipleSeries property Series to be a collection of type that is not collection itself, i.e. List<Point>.

To be able to display multiple series within the Graph you may introduce a grouping property in the Point model (i.e. property Group) and group the corresponding Graph SeriesGroup by this property. This will result in separate Series for each distinct value of Point.Group.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Spencer
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or