adding info objects

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Alexander Weber

adding info objects

Post by Alexander Weber » Tue Mar 26, 2002 4:28 pm

Hi,

there was a topic some day's ago, about "bar and mouse event" (see http://www.object-refinery.com/phorum-3 ... 410&t=1410). As it seems for now, there is no support for getting all needed infomations out of the graph easily (most use the tooltips to identify the related bar) - so i decided that i will add a 'info' object beside the tooltip object, which can hold all the needed informations (category, serie, value, ...?). So it will be easier to get the related informations in the "handleClick" functions (by functions like infoObject.getCategory(x, y), ...).

So David, if that is needed by more people it will be best that i will write it conform to your stuff. I thought about making a new dirctory for that info class (suggestions for the name?).
Perhaps i can implement the listener interface so someone can 'listen' for people clicking on the bars and does not need to overload the handleClick function - do you think that will make sense?
Any other suggestions, hints?

regards,
Alex :)

David Gilbert

Re: adding info objects

Post by David Gilbert » Tue Mar 26, 2002 11:36 pm

Hi Alex,

JFreeChartPanel keeps the DrawInfo object from the last redraw of the chart. So when you click on the panel, that's a good source of information on the structure of the chart. Add any extra things you want to alongside the tooltips in the DrawInfo class.

The handleClick method is really only required if you need to change the state of the chart in some way, in response to a click. At the moment, the anchor point and the crosshair locations are updated.

I couldn't think of a good way to implement a listener mechanism for clicks, given that the components in the chart (bars, lines etc) are a bit transient, just getting drawn on the fly. You would need the chart to maintain all the same state information that is in the DrawInfo object.

All of this code is recent though, and I haven't reviewed it all properly yet, so I'll be happy to hear other views...

Regards,

DG.

Locked