1

我有这个问题,我的所有列栏都聚集在一起,我尝试按字段和其他字段更改顺序,它似乎不起作用。

代码:

 try
            {
                MultiView1.Visible = true;
                Chart1.Series.Clear();
                Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray;
                Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
                MultiView1.Visible = true;
                DataTable table = new DataTable();
                table.Columns.Add("AverageGrading");
                table.Columns.Add("Date");
                ArrayList listofdates = dbmanager.GetListofDatesViaAll();

                foreach (DateTime date in listofdates)
                {
                    double gradingresult = dbmanager.GetAverageAppraisalForSectionALL(date);

                    string monthname = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month);
                    table.Rows.Add(gradingresult, monthname.Substring(0, 3) + "/" + date.Year.ToString().Substring(2, 2));
                }
                DataTableReader datareader = table.CreateDataReader();
                Chart1.ChartAreas[0].AxisX.Title = "Period of appraisal";
                Chart1.ChartAreas[0].AxisY.Title = "Average grade";
                Chart1.DataBindCrossTable(datareader, "Date", "Date", "AverageGrading", "");
                Chart1.Legends.Add("Legend");
                Chart1.Legends[0].Enabled = true;
                Chart1.Legends[0].BackColor = System.Drawing.Color.Transparent;
                Chart1.Width = 1000;
                Chart1.Height = 600;

                MultiView1.ActiveViewIndex = 0;
            }
            catch (Exception e)
            {
                MultiView1.Visible = false;
                MessageBoxShowWithoutredirect(e.Message);
            }

如图所示,这张图表聚集在一起,显示的日期仅为底部的 5 月,这是不正确的。

4

1 回答 1

0

看看这个简单的例子提供给她:http ://www.asp.net/web-pages/tutorials/data/7-displaying-data-in-a-chart 。

希望这可以帮助。

于 2012-06-18T11:22:05.157 回答