ZedGraph - 添加阈值线
这可能很简单,但我无法弄清楚。我有每个操作系统性能计数器的线性图(Y->值,x->时间)。现在,我想为阈值 Y 值(例如红色)添加一条水平直线,以便它与实际数据一起显示在图表中。我已经知道每个计数器的阈值。
我该怎么做?
我目前这样做是为了在自己的选项卡页面中显示性能计数器:
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();
tPage.Controls.Add(zedGraph);
tabControl1.TabPages.Add(tPage);
tabControl1.SelectedTab = tPage;
grpOutput.Visible = true;
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();
tPage.Controls.Add(zedGraph);
tabControl1.TabPages.Add(tPage);
tabControl1.SelectedTab = tPage;
grpOutput.Visible = true;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将 LineObj 添加到 GraphObj 列表来在图形上绘制一条简单的红线,即绘制一条水平线
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