I have two curves on the zedgraph control, after plotting both the curves…
PointPairList thresholdList = new PointPairList();
PointPairList powerList = new PointPairList();
private void plotPower()
{
// Create an object to access ZedGraph Pane
GraphPane pane = zedGraphControl1.GraphPane;
LineItem thresholdLine = new LineItem("thresholdLine");
LineItem powerLine = new LineItem("powerLine");
// Set the Threshold Limit
double thresoldLimit = Convert.ToDouble(numAnalysisThreshold2.Value);
// Points
double[] x = new double[]{0, pane.XAxis.Scale.Max};
double[] y = new double[]{thresoldLimit, thresoldLimit};
// Set the threshold line curve list
thresholdList.Add(x, y);
// Set the Power Line curve list
powerdList.Add(XData, YData);
// Add Curves
thresholdLine = pane.AddCurve("", thresholdList, Color.Red, SymbolType.None);
powerLine = pane.AddCurve("", powerList, Color.Red, SymbolType.None);
// Refresh Chart
this.Invalidate();
zedGraphControl1.Refresh();
}
from the above code, I managed to plot the two curves as power line curve over the threshold line curve.
Now my questions is, if I want to bring any one of the curve in front….Is there any method available(ex: bringittoFront()….)…?
Thanks a lot for your time ….:)
The GraphPane contains a CurveList property, and the CurveList class is a subclass of
List<CurveItem>. If you set the CurveItem.Tag property for each curve that you draw, I believe you should be able to sort the curve items by using theCurveList.Sort(IComparer<CurveItem>)method and using theTagto represent the sorting order.UPDATE JUNE 19
Simple example: two lines, the blue
line2withline2.Tag = 2and the redline1withline1.Tag = 1. In the initializationline2is added first to the graph pane, so it will be displayed on top.To sort, first implement a class that implements
IComparer<CurveItem>, and that sorts the curve items in ascending order based on the numerical value of theCurveItemTagproperty:To perform re-sorting and update the graph, implement the following event handler for the Sort button:
Now, when clicking the Sort button, the curves will be sorted such that the curve with the lowest tag value, i.e.
line1, will instead be drawn on top. Additionally, note that the curve order in the legend is changed along.