Chart控件的使⽤--滚动条、曲线设置及标题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;//纵
win10滚动条设置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集合下选择要显⽰的数据查看是什么格式。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论