我正在使用aSystem.Windows.Forms.DataVisualization.Chart
绘制一些x,y散点数据,如下所示:
chart1.Series["Series2"].Points.AddXY(stringX, doubleY);
我想在该图表上添加一条水平线,其平均值为y =常数。我怎样才能做到这一点?请注意,x轴是一个字符串
实际上,x轴是时间(hh:mm:ss)。我将其转换为字符串以进行绘制,因为如果我将DateTime格式用于图表的x轴(XValueType),则不会显示秒。我可以更正以显示秒数,以便直接将x绘制为DateTime并将y绘制为double吗?
对于第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";
对于点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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句