Converting pointerlocation to values in a categoryplot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
samoht
Posts: 12
Joined: Wed Jun 18, 2008 12:25 pm
Location: Norway

Converting pointerlocation to values in a categoryplot

Post by samoht » Fri Aug 01, 2008 8:08 am

Is there some way of converting the pointerlocation on the chart to corresponding values in a category-plot? I'm using Year as the category value. I would like to know the year I'm clicking on in the chart.
I have done this on XY-Plots, but Im not sure if this is possible in a category-plot?

One more thing, would there be much work creating a CategoryAnnotationEntity so that one could record clicks on this item?

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Post by paradoxoff » Fri Aug 01, 2008 8:23 am

Hi,
the approach to get informations on the point where the mouse was clicked should be similar for both CategoryPlot and XYPlot. If you register a ChartMouseListener to the JFreeChart, you should be able to get the ChartMouseEvent and the corresponding ChartEntity. For a CategoryPlot that should be a CategoryItemEntity (provided that all hot spots are correctly created when the chart is drawn). From the CategoryItemEntity (http://www.jfree.org/jfreechart/api/jav ... ntity.html) you should get all the infos that you want.
Regards, paradoxoff

samoht
Posts: 12
Joined: Wed Jun 18, 2008 12:25 pm
Location: Norway

Post by samoht » Fri Aug 01, 2008 8:37 am

Thank's for your reply.

I might have been a little unclear. If I'm not clicking an entity at all but just clicking the chart. Could I get the value where I'm clicking? In an XY-plot I would use : java2DToValue()

I would also like to capture a click event on a CategoryAnnotation, but there is no CategoryAnnotationEntity that extends ChartEntity, would it be much work to create something like this?

-Thomas

Locked