How to draw candle charts in C#

2019-06-17 04:47发布

问题:

How can I draw candle charts in C#? Does anybody has any examples with a nice interface?

回答1:

I've used the MSChart and found it to be pretty good. It supports candlestick charts. I've used ZedGraph as well but found a few graphical anomalies showed up on my charts but they were otherwise good as well.



回答2:

I use this for stock data but its in VB

        With Chart1.ChartAreas("myarea")
            .AxisY.Maximum = (Math.Ceiling((HighValue * 100)) / 100)
            .AxisY.Minimum = (Math.Floor((LowValue * 100)) / 100)
            .AxisY.LabelStyle.Format = "{0.00}"
        End With

        Dim s1 As New Series
        With s1
            .ChartArea = "myarea"
            .ChartType = SeriesChartType.Candlestick
            .XValueType = ChartValueType.String
            .YValueType = ChartValueType.Single
            .YValuesPerPoint = 4
            .CustomProperties = "PriceDownColor=Red, PriceUpColor=Green"
        End With


        For i = Globals.GraphColumns - 1 To 0 Step -1
            OutData = Data_Array.Item(i)

            s1.Points.AddXY(OutData.thedate, OutData.high, OutData.low, OutData.close, OutData.open)


        Next


        Chart1.Series.Add(s1)
        Me.Controls.Add(Chart1)


回答3:

I'm using the .netCharting library for this and it's pretty good. It supports all sorts of charts - candle included. One thing to watch out for is that with the current version (5.3) you have to reverse the high and low price - a pretty ugly and obvious bug. It's a commercial product, but reasonably priced, so could be worth it, depending on your project.



回答4:

ZedGraph is a very easy-to-use LGPLed charting library that can handle candlestick charts.

If you need to save an image to disk, it can do that. If you need to display an interactive graph that supports zooming/panning, it can do that as well with the excellent ZedGraphControl control.



回答5:

Maybe ChartDirector can be a good solution

http://www.advsofteng.com/doc/cdcomdoc/candlestick.htm



回答6:

Try xamChart Control Trial version from Infragistics.

Here is another sample at CodeProject



标签: c# .net charts