2

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

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

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();

EDIT: 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.

Community
  • 1
  • 1
gbmhunter
  • 1,747
  • 3
  • 23
  • 24
  • I don't know much about the `PointObj` class, but why do you need to call `zedGraph.Invalidate`? Does `point.Draw` not display the point on its own? – Jodaka Jan 17 '13 at 17:25
  • It is my belief that point.Draw adds the point object to the graph object, and then .Invalidate is used to redraw the graph with all the current included objects. – gbmhunter Jan 24 '13 at 22:59
  • Got a picture? Why do you use pointsObj if the same functionality exists in vanilla Zedgraph? – john k Feb 25 '14 at 19:47
  • No picture sorry, this question was asked ages ago :-) But, this is vanilla Zedgraph (PointObj is part of ZedGraph).And the other way seems more like a hack, this seems like the proper way of adding a point. – gbmhunter Feb 25 '14 at 23:48

1 Answers1

0

Try adding the point to the GraphObjList after creation

zedGraph.GraphPane.GraphObjList.Add(point);

user3806381
  • 51
  • 1
  • 3