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

How to Dynamically Create Line Series for a Report

2 Answers 46 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
vikas
Top achievements
Rank 1
vikas asked on 28 Mar 2017, 08:24 PM

I have a report that gets created dynamically. The report houses a Line Graph. The number of Line Series for this Graph can only be determined at run-time. I am able to add the Line Series to the graph dynamically, however, all the values in the LineGraph are same. Can you tell me how can I create a series and set the 'Y' value of the LineSeries?

In case of Telerik Web UI LineSeries, I can create a CategorySeriesItem, assign it values and then add it to LineSeries. However, no such facility seem to exist for Telerik Reporting LineSeries.

Here is my Reporting Code after InitializeComponent().

foreach(var obj in MyList)
{
Telerik.Reporting.LineSeries ls = new Telerik.Reporting.LineSeries();
ls.Name = obj.Name;
...
...
  foreach(var subObj in obj)
  {
     // How do I assign a series of values such as {100,105,109,..} to ls.Y ????
  }
graph1.Series.Add(ls);
 
}

2 Answers, 1 is accepted

Sort by
0
vikas
Top achievements
Rank 1
answered on 29 Mar 2017, 06:54 PM
I've found the solution for this issue. I was able to bind the the data to Line Series to the datasource such that the values don't repeat.
0
Stef
Telerik team
answered on 30 Mar 2017, 01:16 PM
Hello vikas,

In general, you need a single data source that represents flatten data (tabular representation of data).
Then you can use a field that determines the slots on the X axis - the field will be used in the Graph.CategoryGroups.Groupings collection.
Follows a field that will be used as Graph.Series.Y value. The Y axis will be generated based on that field.

If you have separate fields for each Y value, you can add series in the Graph.Series collection for each column, and to set the Y property of each series element.
If you have a field specifying that the value is of a specific line, then you can use that field in the Graph.SeriesGroups.Groupings collection which will generate series(lines) dynamically based on data.

For more details, please check Graph: Structure and Graph Connecting to Data.


I hope this helps.

Regards,
Stef
Telerik by Progress
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
vikas
Top achievements
Rank 1
Answers by
vikas
Top achievements
Rank 1
Stef
Telerik team
Share this question
or