我用a System.Windows.Forms.DataVisualization.Chart来绘制一些x,y散射数据,如下所示:
chart1.Series["Series2"].Points.AddXY(stringX, doubleY);
Run Code Online (Sandbox Code Playgroud)
我想在该图表中添加一条水平线,其平均形式为y =常数.我怎样才能做到这一点?请注意,x轴是一个字符串
实际上,x轴是时间(hh:mm:ss).我正在将它转换为字符串以绘制它,因为如果我使用DateTime格式的图表的x轴(XValueType)它不显示秒.我可以更正显示秒数,这样我可以直接将x绘制为DateTime,将y绘制为double吗?
Jun*_*ith 15
对于第2点,您仍然可以设置为XValueType,DateTime但格式正确LabelStyle.
chart1.Series[SeriesName].XValueType = ChartValueType.DateTime;
// Use the required format. I used the below format as example.
chart1.ChartAreas[ChartName].AxisX.LabelStyle.Format = "dd/mm/yy hh:mm:ss";
Run Code Online (Sandbox Code Playgroud)
对于第1点,将a添加StripLine到图表区域的Y轴.
StripLine stripline = new StripLine();
stripline.Interval = 0;
stripline.IntervalOffset = average value of the y axis; eg:35
stripline.StripWidth = 1;
stripline.BackColor = Color.Blue;
chart1.ChartAreas[ChartAreaName].AxisY.StripLines.Add(stripline);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17329 次 |
| 最近记录: |