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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Create charts dynamically base on user data

Thread ID:





130261 May 3,2017 08:21 AM UTC May 3,2017 12:15 PM UTC ASP.NET Web Forms 3
Tags: Chart
Trinh Thang Long
Asked On May 3, 2017 08:21 AM UTC


I am working on a ASP.NET web form project which need to create several charts by using data from CSV files,
Currently I don't know how to create charts dynamically using behind code (.cs code) instead of  the <ej:Chart> tag predefined in the .aspx file.
For example, I have several CSV files (which I don't know exactly number of files beforehand because they are created by the end-user), like data1.csv, data2.csv...dataN.csv 
I would like to plot N graphs from those data files automatically each time the web page loaded. 
I've tried to search on the forum and KB for awhile but still not find the answer.

P/s: I don't want to use the multiple panes solution because the data format and scale are different so they should be separated to different graphs

Saravana Kumar Kanagavel [Syncfusion]
Replied On May 3, 2017 11:16 AM UTC

Hi Trinh, 
We have analyzed your query and created a sample based on your requirement. In the sample, we are dynamically creating the chart without using <ej:Chart> tag in ASPX page and we have bind the data from the CSV file to the chart. 
Please find the code example below 
            List<ChartData> list = new List<ChartData>(); 
            string path = Server.MapPath(@"~\App_Data\ChartData.csv"); 
            using (var fs = File.OpenRead(path))  
            using (var reader = new StreamReader(fs)) 
                while (!reader.EndOfStream) 
                    var line = reader.ReadLine(); 
                    var values = line.Split(','); 
                    list.Add(new ChartData(values[0], Convert.ToDouble(values[1]))); 
            Syncfusion.JavaScript.Web.Chart chart = new Syncfusion.JavaScript.Web.Chart(); 
            chart.PrimaryXAxis.ValueType = AxisValueType.Category; 
            Series series1 = new Series(); 
            series1.XName = "Xvalue"; 
            series1.YName = "YValue1"; 
            chart.DataSource = list; 
            chart.Size.Height = "450"; 
            chart.Size.Width = "600"; 
In the above code, we are getting the data from .csv file with specific path and binding that data to the chart series. Find the output of the sample below 
And please find the data in .csv file from the below 
We have attached the sample for your reference. And you can change this with respect to your requirement. 
Please let us know if you have any concern.

Saravana Kumar K 

Trinh Thang Long
Replied On May 3, 2017 11:31 AM UTC

Excellent! This is exactly what I need, thank you very much for your quickly support!

Saravana Kumar Kanagavel [Syncfusion]
Replied On May 3, 2017 12:15 PM UTC

Hi Trinh, 
Thanks for your update. 
Please let us know if you need any further assistance on this. 
Saravana Kumar K. 


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

or the page will be automatically redirected to 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