Multiple columns chart using asp.net chart control

2019-06-26 05:34发布

问题:

I need to show the data columns in multiple column chart, I have used single column charts, but I cant find the way to bind another Y-Axis column to the chart

I have data in following format

Name      DataField-1    DataField-2
Emp-a     200               220
Emp-b     150               250 

回答1:

I have found the following link useful for the problem.
http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx

If any one have better suggestion than this please post.

Find another solution like following..

double[] array1 = { 2.8, 4.4, 6.5, 8.3, 3.6, 5.6, 7.3 };
double[] array2 = { 2.0, 4.0, 6.1, 7.8, 2.5, 5.0, 6.2 };

chart1.Series.Add("Series1");
chtStudentResult.Series["Series1"].Points.DataBindY(array1);
chtStudentResult.Series.Add("Series2");
chtStudentResult.Series["Series2"].Points.DataBindY(array2);

It will generate the desired multiple column, column chart.



回答2:

It's very easy.

  1. You just go to your properties of Chart control. There is a property called series.

  2. Click on that and give the two series you need to show in the Chart. Eg: DataField-1 , DataField-2 in your case.

  3. Then simply go to the chart and attach Data-Source to your chart control.

  4. Then you will get two XAxis and YAxis.

  5. Then select the correct axis values.