ZedGraph - 添加阈值线

发布于 2024-11-07 17:18:06 字数 1064 浏览 0 评论 0原文

这可能很简单,但我无法弄清楚。我有每个操作系统性能计数器的线性图(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小巷里的女流氓 2024-11-14 17:18:06

您可以通过将 LineObj 添加到 GraphObj 列表来在图形上绘制一条简单的红线,即绘制一条水平线

double threshHoldY = 2;
LineObj threshHoldLine = new LineObj(
    Color.Red,
    graphPane.XAxis.Scale.Min,
    threshHoldY,
    graphPane.XAxis.Scale.Max,
    threshHoldY);
graphPane.GraphObjList.Add(threshHoldLine);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文