将点对象添加到ZedGraph [英] Adding Point Objects To 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屋!