I used a code in order to display a graph. I want to insert a button in this graph (Show details) that i will used in order to present some details about the graph .It is realis
Add a ChartMouseListener
to the ChartPanel
that contains your chart. You can get details about the PieSectionEntity
that was clicked as shown below. See the implementation of toString()
in PieSectionEntity
for more. Optionally, you can highlight the entity as shown here.
ChartPanel panel = new ChartPanel(chart);
panel.addChartMouseListener(new ChartMouseListener() {
@Override
public void chartMouseClicked(ChartMouseEvent e) {
ChartEntity entity = e.getEntity();
if (entity instanceof PieSectionEntity) {
PieSectionEntity pse = (PieSectionEntity) entity;
System.out.println(pse);
}
}
@Override
public void chartMouseMoved(ChartMouseEvent event) {
}
});