zoukankan      html  css  js  c++  java
  • DataTable +chart控件

    //这是仿你的DataTable

    6ae3d436-d3b7-3905-835e-ee28757239c3.png

                //-----开始---------

                DataTable dataTable1 = new System.Data.DataTable();

                dataTable1.Columns.Add("网别", typeof(string));

                dataTable1.Columns.Add("日期", typeof(DateTime));

                dataTable1.Columns.Add("日发展", typeof(double));

                DataTable dataTable2 = dataTable1.Clone();

                DataTable dataTable3 = dataTable1.Clone();

                dataTable1.Rows.Add("网别1", new DateTime(2014, 1, 1), 12.0);

                dataTable1.Rows.Add("网别11", new DateTime(2014, 2, 1), 14.0);

                dataTable2.Rows.Add("网别2", new DateTime(2014, 1, 1), 5.0);

                dataTable2.Rows.Add("网别2", new DateTime(2014, 2, 1), 10.0);

                dataTable3.Rows.Add("网别3", new DateTime(2014, 1, 1), 7.0);

                dataTable3.Rows.Add("网别31", new DateTime(2014, 2, 1), 18.0);

                //---------结束-------------

                chart1.Series.Clear();//清空表中的数据

                //第一个表中的数据

                Series dataTable1Series = new Series("dataTable1");

                dataTable1Series.Points.DataBind(dataTable1.AsEnumerable(), "日期", "日发展", "");

                dataTable1Series.XValueType = ChartValueType.DateTime; //设置X轴类型为时间

                dataTable1Series.ChartType = SeriesChartType.Line;  //设置Y轴为折线

                chart1.Series.Add(dataTable1Series);

                //第二个表中的数据

                Series dataTable2Series = new Series("dataTable2");

                dataTable2Series.Points.DataBind(dataTable2.AsEnumerable(), "日期", "日发展", "");

                dataTable2Series.XValueType = ChartValueType.DateTime;//设置X轴类型为时间

                dataTable2Series.ChartType = SeriesChartType.Line;  //设置Y轴为折线

                chart1.Series.Add(dataTable2Series);

                //第三个表中的数据

                Series dataTable3Series = new Series("dataTable3");

                dataTable3Series.Points.DataBind(dataTable3.AsEnumerable(), "日期", "日发展", "");

                dataTable3Series.XValueType = ChartValueType.DateTime;//设置X轴类型为时间

                dataTable3Series.ChartType = SeriesChartType.Line;  //设置Y轴为折线

                chart1.Series.Add(dataTable3Series);

  • 相关阅读:
    lintcode254- Drop Eggs- easy
    lintcode462- Total Occurrence of Target- easy
    lintcode63- Search in Rotated Sorted Array II- medium
    lintcode62- Search in Rotated Sorted Array- medium
    lintcode74- First Bad Version- medium
    lintcode75- Find Peak Element- medium
    lintcode160- Find Minimum in Rotated Sorted Array II- medium
    lintcode159- Find Minimum in Rotated Sorted Array- medium
    lintcode447- Search in a Big Sorted Array- medium
    VS2005、vs2008+WinXPDDK+DDKWizard配置驱动开发环境 分类: VC++ 2015-01-05 09:38 448人阅读 评论(0) 收藏
  • 原文地址:https://www.cnblogs.com/gosteps/p/5289910.html
Copyright © 2011-2022 走看看