ZedGraph Vertical Lines with LineObj Release

I have a ZedGraphControl with a few curves in it, and I want to add vertical lines at some fixed x positions. Of course, the lines should be inside the area of ​​the actual graph.

I tried to follow

LineObj line = new LineObj(Color.Black, xPos, myPane.YAxis.Scale.Min, xPos, myPane.YAxis.Scale.Max);  
line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
line.Line.Width = 1f;
myPane.GraphObjList.Add(line);

and this works great until the user enlarges the graph, the vertical lines will stretch out of the actual area of ​​the graph (see. Fig. link below, also note that it is not broken on the graph, odd).

http://imageshack.us/photo/my-images/196/zedgraphzoom.png/

Is there a way to solve this problem (if there was a way to get myPane.Xaxis.Scale.Min and Max of the current zoom, and then update the graph in ZoomEvent?), Or are there any better classes / methods to use for this purpose, except LineObj?

+5
2

LineObj a LineItem GraphPane.CurveList:

LineItem line = new LineItem(String.Empty, new[] { xPos, xPos },
                new[] { myPane.YAxis.Scale.Min, myPane.YAxis.Scale.Max }, 
                Color.Black, SymbolType.None);
line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
line.Line.Width = 1f;

myPane.CurveList.Add(line);

line , , line, . , y line, line .

, ; , , LineItem .

+2

, LineObj, CurveItem,

Location struct CoordinateFrame. X / Y.

CoordinateFrame XScaleYChartFraction 0d 1d Y, "" "" ( YAxis.Scale.Min YAxis.Scale.Max), X X Axis.

, .AxisChange(), , , LineObj Y!

var line = new LineObj(Color.Black, xPos, 0, xPos, 1);

line.Location.CoordinateFrame = XScaleYChartFraction; // This do the trick !
line.IsClippedToChartRect = true;

line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
line.Line.Width = 1f;

myPane.GraphObjList.Add(line);
+3

All Articles