我需要在运行时动态添加图表。实际上是多个图表。例如:我必须从数据库中获取 14 周的记录并在每周的图表中显示记录。(即 14 个图表)。但是数字周可能因用户和图表而异。那么,我该如何克服这个问题呢?
我很感谢有关此的任何想法。
图表 Chart1 = new Chart();
Chart1.Series.Add(new Series());
Chart1.ChartAreas.Add(new ChartArea());
Chart1.ChartAreas[0].Area3DStyle.Enable3D = false;
Chart1.Series[0].YValueMembers = "Value";
Chart1.Series.Add(new Series());
Chart1.Series[1].YValueMembers = "AnotherValue";
Chart1.DataSource = lsttest;
Chart1.DataBind();
Chart1.Series[0].Color = Color.Blue;
Chart1.Series[1].Color = Color.DarkGreen;
Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Count";
Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Status";
Chart1.Series[0].IsValueShownAsLabel = true;
Chart1.Series[1].IsValueShownAsLabel = true;
Chart1.ImageType = System.Web.UI.DataVisualization.Charting.ChartImageType.Jpeg;
Chart1.Width = new System.Web.UI.WebControls.Unit(300, System.Web.UI.WebControls.UnitType.Pixel);
Chart1.Height = new System.Web.UI.WebControls.Unit(200, System.Web.UI.WebControls.UnitType.Pixel);