ZedGraph - Adding threshold line
This may be simple, but I'm unable to figure it out. I have a linear graph for each of the OS performance counters (Y->value, x->Time). Now I want to add a straight horizontal line for a threshold Y value in, say, Red so that it shows in the graph along with the actual data. I already know the threshold value for each of my counters.
How do I do this?
I currently do this to show a perfcounter in its own tabPage:
Cursor = Cursors.WaitCursor;
var perfCounter = PerfDictValues.Value.First(pc => pc.Counter == counter);
var tPage = new TabPage((tabControl1.TabPages.Count + 1).ToString());
tPage.Tag = perfCounter;
tPage.Padding = new Padding { All = 8 };
var zedGraph = new ZedGraphControl();
zedGraph.Dock = DockStyle.Fill;
var graphPane = zedGraph.GraphPane;
graphPane.Title.Text = counter;
graphPane.XAxis.Title.Text = String.Format("Max: {0}, Min: {1}, Avg: {2}", perfCounter.Maxm, perfCounter.Min, perfCounter.Average);
var curve = graphPane.AddCurve(counter, perfCounter.PointList, Color.Blue, SymbolType.Diamond); //Want to add a threshold value from perfCounter.Threshold property
graphPane.XAxis.Type = AxisType.Linear;
graphPane.AxisChange();
t开发者_StackOverflow社区Page.Controls.Add(zedGraph);
tabControl1.TabPages.Add(tPage);
tabControl1.SelectedTab = tPage;
grpOutput.Visible = true;
You can draw a simple red line on the graph by adding a LineObj to the GraphObj list, i.e. this draws a horizontal line
double threshHoldY = 2;
LineObj threshHoldLine = new LineObj(
Color.Red,
graphPane.XAxis.Scale.Min,
threshHoldY,
graphPane.XAxis.Scale.Max,
threshHoldY);
graphPane.GraphObjList.Add(threshHoldLine);
精彩评论