将点对象添加到ZedGraph [英] Adding Point Objects To ZedGraph

查看:114
本文介绍了将点对象添加到ZedGraph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ZedGraph可以很好地扩展以绘制标记/点( PointObj.cs ).但是,我无法在图形上绘制点.

A nice extension exists for ZedGraph to plot markers/points (PointObj.cs). However, I am having trouble rendering the point on the graph.

当我调用ZedGraph.Invalidate()函数时,标记会暂时绘制,然后消失.

When I call the ZedGraph.Invalidate() function, the marker is drawn momentarily but then disappears.

在以下代码中,变量zedGraph是表单UI上的可见图形对象.

In the following code, the variable zedGraph is the visible graph object on the form UI.

 // Create point
 ZedGraph.PointObj point = new ZedGraph.PointObj(5, 10000, 50, 50, ZedGraph.SymbolType.Square, Color.Green);
 ZedGraph.PaneBase paneBase = zedGraph.GraphPane;
 point.Fill = new ZedGraph.Fill(Color.Green);
 System.Drawing.Graphics graphics = zedGraph.CreateGraphics();

 // Draw point to graph
 point.Draw(graphics, paneBase, paneBase.CalcScaleFactor());

 // Re-draw graph, but point only flashes momentarily. 
 zedGraph.Invalidate();

我意识到还有其他添加点"的方法,例如此处所述(

I realise there are other ways of adding "points", such as described here (Labelling and circle a specific point in zedgraph). But it would be still good to know why this doesn't work.

推荐答案

创建后尝试将点添加到GraphObjList

Try adding the point to the GraphObjList after creation

zedGraph.GraphPane.GraphObjList.Add(point);

zedGraph.GraphPane.GraphObjList.Add(point);

这篇关于将点对象添加到ZedGraph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆