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

Need Chart code sample

Thread ID:





124695 Jun 23,2016 05:35 AM UTC Jun 23,2016 12:28 PM UTC ASP.NET Web Forms 1
Tags: Chart
Asked On June 23, 2016 05:35 AM UTC

I need code for add series and assign datasource in code behind side in vb.net or C# for chart controls

Sanjith Kesavan [Syncfusion]
Replied On June 23, 2016 12:28 PM UTC

Hi Sathayaraj, 

Thanks for contacting Syncfusion support. We have analyzed your query and prepared sample as per your requirement. For add the series and datasource for the series in code behind, please follow the below code. 

<ej:Chart runat="server" ID="Chart1"></ej:Chart> 

protected void Page_Load(object sender, EventArgs e) 
            Series series = new Series(); 
            series.Type = Syncfusion.JavaScript.DataVisualization.SeriesType.Spline; 
            List<data> data = new List<data>(); 
            data.Add(new data(1, 20)); 
            data.Add(new data(2, 30)); 
            data.Add(new data(3, 10)); 
            data.Add(new data(4, 15)); 
            data.Add(new data(5, 30)); 
            series.DataSource = data; 
            series.XName = "xvalue"; 
            series.YName = "yvalue"; 

In the above code, we have initialized the chart in the ASPX page. In code behind, we have created the series for the chart and added datasource for it. Now the chart will render like below. 

In the below link, we have attached sample for your reference. 
Sample link: C#sample 

Same procedure applies for VB.Net also. Please find the below code, what we have written in VB.Net for create the series in code behind and add datasource for it.  

Dim series As New Series() 
        series.Type = Syncfusion.JavaScript.DataVisualization.SeriesType.Spline 
        Dim data As New List(Of data)() 
        data.Add(New data(1, 20)) 
        data.Add(New data(2, 30)) 
        data.Add(New data(3, 10)) 
        data.Add(New data(4, 15)) 
        data.Add(New data(5, 30)) 
        series.DataSource = data 
        series.XName = "xvalue" 
        series.YName = "yvalue" 

Please find the sample from the below link. 
Sample link: VBsample 



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