We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

adding series to the chart from server side code.

Thread ID:





143281 Mar 12,2019 07:38 PM UTC Mar 14,2019 06:49 AM UTC ASP.NET MVC - EJ 2 3
Tags: Chart
Gideon Keys
Asked On March 12, 2019 07:38 PM UTC

I have a line chart that I want to populate with data from a database. The problem I'm having is the amount of series I need changes depending on the data that the user wants from the database. I can't find anything in the documentaion about this. Maybe I am looking in the wrong place. Or going about this the wrong way. Any help would be greatly appreciated. 

Dharanidharan Dharmasivam [Syncfusion]
Replied On March 13, 2019 11:47 AM UTC

Hi Gideon, 
Greetings from Syncfusion. 
We have analysed your query. We have prepared a sample based on your requirement. In that we have created multiple list of data in server side and store all collections in ViewBag. Then dynamically add series in view page based on data length. Please find below snippet, 
Code Snippet: 
    var count = Enumerable.Count(ViewBag.Items); 
     .Series(series => 
            for(var i=0; i< count; i++) { 
public ActionResult ChartFeatures() 
List<List<DoubleAxisData>> data = new List<List<DoubleAxisData>>(); 
//Other configurations 
ViewBag.Items = data; 
return View(); 
Hope this helps. 

Gideon Keys
Replied On March 13, 2019 08:05 PM UTC

Thank you. That worked great!

Dharanidharan Dharmasivam [Syncfusion]
Replied On March 14, 2019 06:49 AM UTC

Hi Gideon, 
Most welcome. Kindly get in touch with us, if you require further assistance. We are always happy in assisting you. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon