Question

I have an OHLC stock price chart in Zedgraph. I would like to add multiple line segments on this graph where I only know the start and end point values - so basically, I have a (start date, price) and an (end date, price) combination of 2 points which I want to draw a line through.

enter image description here

I tried using the following code but this adds all the lines to the beginning of the graph, irrespective of the x-axis value that I provide.

LineItem trendLine = new LineItem(String.Empty, new[] { pstartDate, pconfirmDate },   new[] { pstartPrice, pconfirmPrice }, System.Drawing.Color.Black, SymbolType.None);
trendLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Solid;
trendLine.Line.Width = 1f;
pricePane.CurveList.Add(trendLine);

Thanks in advance.

NEW OBSERVATIONS - My OHLC graph currently has scrolling and zoom across X-axis enabled. I am using the X-Axis Type 'DateAsOrdinal'. I observed that if I change my X-Axis type to 'Date', the line segments appear as they should, i.e., in the correct place along the X-Axis. But now the scroll has become disabled and the data that was originally being displayed is only partially displayed now!

Was it helpful?

Solution

For a trend line you should rather use LineObj.

If your XAxis is DateAsOrdinal, the x values must be ordinal, not dates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top