Clickable legends?
Clickable legends?
Pre-1.0, when you clicked on a legend, a ChartMouseEvent was generated whose Entity was a LegendItemEntity. Of course, now that legends are no different from any other title, these events are no longer thrown. I tried using the LegendTitle's getBounds() and related methods, but they return zeros. Has anyone come up with a good way to handle clicking on legends?
-
- Posts: 3
- Joined: Wed Mar 22, 2006 10:52 pm
- Contact:
Re: Clickable legends?
Has anybody found a solution for this by now. I only can get the sizes of the single LegendLabelBlocks, but have by now not found a way to retrieve to position of the legendtitle...
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Clickable legends?
Looks OK to me in 1.0.14:
LegendItemEntity java.awt.geom.Rectangle2D$Double[x=249.0,y=458.515625,w=38.0,h=18.484375]
LegendItemEntity java.awt.geom.Rectangle2D$Double[x=289.0,y=458.515625,w=56.0,h=18.484375]
LegendItemEntity java.awt.geom.Rectangle2D$Double[x=347.0,y=458.515625,w=44.0,h=18.484375]
LegendItemEntity java.awt.geom.Rectangle2D$Double[x=249.0,y=458.515625,w=38.0,h=18.484375]
LegendItemEntity java.awt.geom.Rectangle2D$Double[x=289.0,y=458.515625,w=56.0,h=18.484375]
LegendItemEntity java.awt.geom.Rectangle2D$Double[x=347.0,y=458.515625,w=44.0,h=18.484375]
Code: Select all
chartPanel.addChartMouseListener(new ChartMouseListener() {
@Override
public void chartMouseClicked(ChartMouseEvent e) {
String name = e.getEntity().toString().split(":")[0];
System.out.println(name + " " + e.getEntity().getArea());
}
@Override
public void chartMouseMoved(ChartMouseEvent e) {}
});