Win Form Charting

后端 未结 4 1171
不思量自难忘°
不思量自难忘° 2020-12-20 15:59

I may be asking the wrong question, but what I need is to add a \"Guide Line\" to my windows form chart. In other words I have a chart with a simple data series and I need t

4条回答
  •  遥遥无期
    2020-12-20 16:13

    You can add a StripLine.

    Use StripWidth property to set line position:

    var series = chart1.Series[0]; //series object
    var chartArea = chart1.ChartAreas[series.ChartArea];
    chartArea.AxisY.StripLines.Add(new StripLine
                                               {
                                                   BorderDashStyle = ChartDashStyle.Dash,
                                                   BorderColor = Color.DarkBlue,
                                                   StripWidth = 80//Here is your y value
                                               });
    

    UPDATE: Previous version of this answer used Interval instead of StripWidth. As @dthor correctly pointed out in the comments setting the Interval will draw a repeated strip line. In the example above, Interval is set to 0 by default.

提交回复
热议问题