本文介绍了如何在C#中使用DataBindCrossTable防止图表聚类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,我所有的列栏都聚集在一起,我尝试按字段和其他字段更改顺序,这似乎不起作用.
http://stackoverflow.com/questions/10828465/what-to-prevent-clustering-using-databindcrosstable-in-c-sharp-for-chart [ ^ ]
I have this problem where all my column bars is clustered together, i tried changing the order by fields and other fields, it seems not to be working.
http://stackoverflow.com/questions/10828465/what-to-prevent-clustering-using-databindcrosstable-in-c-sharp-for-chart[^]
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);
}
推荐答案
这篇关于如何在C#中使用DataBindCrossTable防止图表聚类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!