1

I want to make a 2D scatter plot with following requirements;

  • The "dots" should not be dots but instead arrows pointing either upwards or downwards depending on the data it represents.
  • It should be possible to specify what values to show on the axis.
  • The user should be able to zoom and pan on the graph.
  • I want to be able to specify what color each arrow should have.
  • The arrows should be clickable (i.e. I need some way to register a click event and decide which arrow was clicked).

I have tried to accomplish this using ZedGraph but I find it hard to get how I want, especially with the first requirement.

Is there a free charting library that would allow me to do this relatively easy in WinForms? Or, any general tips on how to accomplish the first requirement using ZedGraph?

HischT
  • 933
  • 1
  • 9
  • 26

2 Answers2

1

In the Zedgraph samples there is an example of adding text labels to the data points using TextObjects. You can find this demo sample here.

Based on this example, you should be able to create the up and down arrows in required positions, using ArrowObjects instead of TextObjects.

Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114
  • 1
    Thank you for your answer, it works quite well! I have noticed a strange behaviour when adding objects to the GraphObjList though, when zooming or panning the GraphObj's (in my case ArrowObj's) ends up outside the actual graph area (also see this post with the same kind of problem http://stackoverflow.com/questions/11795141/zedgraph-vertical-lines-with-lineobj-issue ). – HischT Aug 09 '12 at 09:57
  • Yes, I realize that this solution is practical primarily for a statically displayed graph. I have not checked, but maybe you can override some zoom/pan event handler and redraw your graph objects there? Might be impractical, but could be worth a shot? – Anders Gustafsson Aug 09 '12 at 10:04
  • 1
    I have tried to get it to work but it simply isn't a clean solution. I figured it is much cleaner to do custom symbol type like in this post http://stackoverflow.com/questions/11879915/customize-symbol-type-of-a-zedgraph-lineitem . Thank you for your help both in this and the linked post. – HischT Aug 09 '12 at 11:47
1

I have now learned that all requirements can be accomplished using ZedGraph.

The "dots" should not be dots but instead arrows pointing either upwards or downwards depending on the data it represents.

The cleanest solution is to use LineItem and do custom symbol type just like in this post Customize symbol type of a ZedGraph LineItem .

It should be possible to specify what values to show on the axis.

An easy solution to this is to use TextLabels and manually place them where you want them.

The user should be able to zoom and pan on the graph.

Functionality built into ZedGraph.

I want to be able to specify what color each arrow should have.

One can create multiple LineItems for each color, this requires that the line itself is not visible though.

The arrows should be clickable (i.e. I need some way to register a click event and decide which arrow was clicked).

Easily made using the Click event and FindNearestPoint method.

Community
  • 1
  • 1
HischT
  • 933
  • 1
  • 9
  • 26