private void BindGrid()
{
chart2.Width = 800;
chart2.Height = 600;
//作图区的显示属性设置
//chart2.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = false;
//chart2.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
//背景色设置
chart2.ChartAreas["ChartArea1"].ShadowColor = Color.Transparent;
chart2.ChartAreas["ChartArea1"].BackColor = Color.FromArgb(209, 237, 254); //该处设置为了由天蓝到白色的逐渐变化
chart2.ChartAreas["ChartArea1"].BackGradientStyle = GradientStyle.TopBottom;
chart2.ChartAreas["ChartArea1"].BackSecondaryColor = Color.White;
//X,Y坐标线颜色和大小
chart2.ChartAreas["ChartArea1"].AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
chart2.ChartAreas["ChartArea1"].AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
chart2.ChartAreas["ChartArea1"].AxisX.LineWidth = 2;
chart2.ChartAreas["ChartArea1"].AxisY.LineWidth = 2;
chart2.ChartAreas["ChartArea1"].AxisX.Title = "时间";
chart2.ChartAreas["ChartArea1"].AxisY.Title = "灰量";
//中间X,Y线条的颜色设置
chart2.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
chart2.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
//X.Y轴数据显示间隔
chart2.ChartAreas["ChartArea1"].AxisX.Interval = 2.0; //X轴数据显示间隔
chart2.ChartAreas["ChartArea1"].AxisX.IntervalType = DateTimeIntervalType.Hours;
chart2.ChartAreas["ChartArea1"].AxisY.Interval = 20;
//X轴线条显示间隔
//chart2.ChartAreas["ChartArea1"].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Hours;
chart2.Palette = ChartColorPalette.Pastel;
string sql = "select sum(zhl) zhl, input_date, ash_type_name from (" +
" select sum(t.second_load - t.first_load) as zhl,"+
" to_date(to_char(t.input_date, 'dd/mm/yyyy hh24')||':00','dd/mm/yyyy hh24:mi:ss') as input_date," +
" u.ash_type_name"+
" from transportation_bill t, ash_type u"+
" where t.ash_type_id = u.ash_type_id" +
" and ((sysdate - t.input_date) between 0.0 and 1.0)"+
" and t.sale_organization_id = 1"+
" group by u.ash_type_name, t.input_date"+
" order by t.input_date"+
")"+
" group by ash_type_name,input_date"+
" order by input_date";
DataTable dt2 = OracleHelper.ExecuteDataTable(OracleHelper.ConnectionString, CommandType.Text, sql, "T", null);
chart2.DataBindCrossTable(dt2.DefaultView, "ash_type_name", "input_date", "zhl", "", PointSortOrder.Ascending);
foreach (Series sr in chart2.Series)
{
sr.ChartType = SeriesChartType.Spline;
sr.XValueType = ChartValueType.Time;
sr.MarkerStyle = MarkerStyle.Circle;
sr.BorderWidth = 2;
}
}