Jfree chart Find Subplot

后端 未结 1 1000
再見小時候
再見小時候 2020-11-30 14:45

This may sound very basic as a question, but i am stuck in JFreechart use.

Let me lay out my problem :

  1. I have a CombinedDomainXYPlot to which I add my
1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 15:24

    You can get a List of subplots using getSubplots(). To learn which subplot was clicked, examine the ChartMouseEvent that was sent from the ChartPanel, as suggested here.

    Addendum: Here's a simple implementation of ChartMouseListener that will show each ChartEntity as it is clicked.

    ChartPanel panel = ...
    panel.addChartMouseListener(new ChartMouseListener() {
    
        @Override
        public void chartMouseClicked(ChartMouseEvent e) {
            System.out.println(e.getEntity().getClass());
        }
    
        @Override
        public void chartMouseMoved(ChartMouseEvent event) {}
    });
    

    0 讨论(0)
提交回复
热议问题