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

binding chart data to a dataset

Thread ID:





88119 Jul 15,2009 03:55 PM UTC Jul 16,2009 07:03 AM UTC ASP.NET Web Forms (Classic) 2
Tags: Chart
Administrator [Syncfusion]
Asked On July 15, 2009 03:55 PM UTC

I'm new to syncfusion and am trying to bind data from a dataset to a syncfusion chart, the code I'm using is as follows:

ChartSeries series1 = new ChartSeries(" Unit Sales ");
series1.Type = ChartSeriesType.Scatter;

ChartDataBindModel dataSeriesModel = new ChartDataBindModel(unitSalesKPI);

series1.SeriesModel = dataSeriesModel;

The data that resides in the dataset looks like this:
full_date value_wtd
2009-03-30 00:00:00.000 8.00
2009-03-31 00:00:00.000 28.00
2009-04-01 00:00:00.000 47.00
2009-04-02 00:00:00.000 55.00
2009-04-03 00:00:00.000 100.00

I could only find 1 example anywhere in the documentation, please advise... thank you!

Administrator [Syncfusion]
Replied On July 15, 2009 05:57 PM UTC

I've actually made some progress on this but cannot get the chart to recognize the data...

The DataSet has the following:

day_of_week_short_desc value_wtd
Mon 8.00
Tue 28.00
Wed 47.00
Thu 55.00
Fri 100.00

day_of_week_short_desc is the x-axis and value_wtd is the y-axis

I'm trying to create a chart. The chart seems to realize that the data is there but the x/y axes and plotting is not correct.

Here is the code that I am using:

ChartSeries series1 = new ChartSeries(" Unit Sales ");
series1.Type = ChartSeriesType.Scatter;
ChartDataBindModel dataSeriesModel = new ChartDataBindModel(unitSalesKPI, "unit_sales_kpi");
series1.SeriesModel = dataSeriesModel;

ChartDataBindAxisLabelModel dataLabelsModel = new ChartDataBindAxisLabelModel(unitSalesKPI, "unit_sales_kpi");
dataLabelsModel.LabelName = "Name"; //"day_of_week_short_desc";
ChartWebControl1.PrimaryXAxis.LabelsImpl = dataLabelsModel;

this.ChartWebControl1.Series[0].ScatterConnectType = ScatterConnectType.Line;

I have attached a picture of the chart that is being produced.

Please advise,

Thank you


Venkata Vijayaraj B [Syncfusion]
Replied On July 16, 2009 07:03 AM UTC

Hi Bill,

Thank you for using Essential Chart.

//To plot dataset's table values, bind the x column and y column of the table to chartDataBindModel's XName, YNames

ChartDataBindModel model = new ChartDataBindModel(dataSet, "Demographics");
model.XName = "ID";
model.YNames = new string[] { "Population" };
series.SeriesModel = model;

If 'XName' property of ChartDataBindModel is not assigned then Chart will taken the X Axis values from Zero [0, 1,
2, ...] automatically and plot the yvalues.

//To set the axis labels

//Set the below property to display the custom labels.
this.ChartWebControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;

private ChartDataBindAxisLabelModel xAxisLabelModel = null;
this.xAxisLabelModel = new ChartDataBindAxisLabelModel(dataSet, "Demographics");
this.xAxisLabelModel.LabelName = "City";

this.ChartWebControl1.PrimaryXAxis.LabelsImpl = this.xAxisLabelModel;

Sample Link:


Please let me know if you need any other detail.



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