开发者

Is there a WinForms line chart control that can individually color segments?

I need a line chart control for Windows Forms that allows me to specify a color for each segment. For example, something like the stock chart shown below.

The problem with rolling my own is that if I draw each segment separately, I don't get the开发者_如何学JAVA benefit of LineJoins such as Miter, Round, or Bevel. If I use Graphics.DrawLines to get the nice joins, I can't control the segment colors individually.

Is there a workaround, or better yet a commercially available chart control that has this kind of flexibility?

Is there a WinForms line chart control that can individually color segments?


The regular MSChart control will do just that, provided you assign each DataPoint a Color..:

Is there a WinForms line chart control that can individually color segments?

Series ser2 = chart1.Series.Add("line");
ser2.ChartType = SeriesChartType.Line;

Random r = new Random(8);
ser2.Points.AddXY(0, 10);
for (int i = 1; i < 60; i++ )
{
    int v = 10 + r.Next(10);
    int p = ser2.Points.AddXY(i, v);
    ser2.Points[p].Color =
        ser2.Points[p - 1].YValues[0] < ser2.Points[p].YValues[0] ?
        Color.Black : Color.Red;

}


Have you looked at the chart control built into Visual Studio 2010? It is very powerful (technology purchased from Dundas)

I know that series can look similar to your included image if you use the "Empty point" average feature

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜