2

I'm using jFreeChart via JFreeChartWrapper in Vaadin and have problems on drawing it. Data for charts is getting in runtime and it could take some time. So I want to add progress indicator to notify the user about image loading (before it closes the window).

I tried to resolve this problem by adding temporary layout for ProgressIndicator and using it until receiving some event from charts:

final AbsoluteLayout loadLayout = new AbsoluteLayout();
loadLayout.setImmediate(true);
ProgressIndicator progress = new ProgressIndicator();
progress.setIndeterminate(true);
progress.setVisible(true);
loadLayout.addComponent(progress, "right: 500px; top: 200px;");
setContent(loadLayout);

Meanwhile, chart are added in another layout:

JFreeChart barChart = ChartFactory.createBarChart("Text", "", "", res, PlotOrientation.VERTICAL, true, false, false); 

barChart.addProgressListener(new ChartProgressListener() {
    @Override
    public void chartProgress(ChartProgressEvent arg0) {
        if (arg0.getType() == ChartProgressEvent.DRAWING_FINISHED) {
            loadLayout.setVisible(false);
            setContent(layout);
            layout.setVisible(true);
        }
    }
}); 
JFreeChartWrapper chartWrap = new JFreeChartWrapper(barChart);
layout.addComponent(chartWrap);

But what I get - is only progress indicator, I never get ChartProgressEvent. And I don't see where this event if fired in JFreeChart.

Is it possible to fix it or I should better use other Vaadin plugin for charts?

1 Answers1

1

To receive such events, you need to add your chart to a ChartPanel, as discussed here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thank you for reply! But I don't use Swing, so if I'll add the chart to a ChartPanel, I still ought to add the chart to a ChartWrapper for displaying in Vaadin. And I still don't receive event. – Alexander Che. Apr 21 '12 at 06:30