1.开启滚动条(ScaleView.Size除以Interval ,大概是中间出现纵线的数量,一般动ScaleView.Size)
chart1.ChartAreas[0].CursorX.AutoScroll = true;
chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
chart1.ChartAreas[0].CursorX.IsUserEnabled = true;
chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisX.ScaleView.Size = 8;
this.chart1.ChartAreas[0].AxisX.Interval = 1;
2.横纵轴线条颜色
this.chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.Red;//横
this.chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.Green;//纵
3.设置标题
this.chart1.Titles.Clear();
this.chart1.Titles.Add("S01");
this.chart1.Titles[0].ForeColor = Color.RoyalBlue;
this.chart1.Titles[0].Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
this.chart1.Titles[0].Text = string.Format("{0} 显示", "时间");
4.绑定数据DataTable:
chart1.SuspendLayout();
this.chart1.DataSource = table;
this.chart1.Series.Clear();
foreach (DataColumn col in table.Columns)
{
if (col.ColumnName == xName)
{
continue;
}
//定义存储和显示点的容器
Series series1 = new Series(col.ColumnName);
//series1.IsValueShownAsLabel = true;
series1.ToolTip = "#VAL{N2}";
series1.ChartArea = "ChartArea1";
series1.XValueType = ChartValueType.DateTime;
series1.ChartType = SeriesChartType.Line;
series1.Points.Clear();
series1.Points.DataBind(table.AsEnumerable(), "x", col.ColumnName, "");
this.chart1.Series.Add(series1);
_seriesList[col.ColumnName] =series1;
}
chart1.ResumeLayout();
5.线条上数据点上是否有数据显示
series.IsValueShownAsLabel = false;
6.线条上的数据点标志类型
series.MarkerStyle =MarkerStyle.None;
//线条数据点的大小
//series.MarkerSize= 8;
7.提示框显示y值
series1.ToolTip = "#VAL{N2}";
数字类型,保留两位小数,详细可以在属性框series集合下选择要显示的数据查看是什么格式。