开发者

JFreeChart chart rendering issue

This question is continue of my previous one, related to non-displaying of data. After the given recommendations, I tried to plot a smaller data range. As it has been observed, when I'm working with the data range of the different size, the rendering time is increasing rapidly. The last (more or less) acceptable data set (that is loading to memory but is not for plotting) contains 16k of values. In case I need to plot only 100 of them, the time of rendering is huge as well.

The plot generation code is as follows:

public void plotXYChart(double dArray[][], String sPlotName, String sSeriesName,
        String sRangeName, int iInitialPoint, int iPlotLength){

    XYSeries series1 = new XYSeries(sSeriesName);
    series1.clear();
    series1.setNotify(false);

    if (iInitialPoint+iPlotLength > dArray.length){
        iPlotLength = dArray.length;
    } else {
        iPlotLength+=iInitialPoint;
    }
    for开发者_JAVA百科 (int i=iInitialPoint; i < iPlotLength; i++){
        series1.add(dArray[i][0], dArray[i][1], false);
    }

    System.out.println("Elements in series: " + series1.getItemCount());

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.removeAllSeries();
    dataset.addSeries(series1);
    System.out.println("Elements in dataset: " + dataset.getItemCount(0));

    chart = null;
    chart = new JFreeChart(new XYPlot(dataset, new NumberAxis(sSeriesName),
    new NumberAxis(sRangeName), new SamplingXYLineRenderer()));

    plotChart(sPlotName, chart);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getDomainAxis().setStandardTickUnits(new StandardTickUnitSource());
    plot.getRangeAxis().setStandardTickUnits(new StandardTickUnitSource());

}

The code for JFramePanel that is using for output of chart is the next one:

    private void plotChart(String sPlotName, JFreeChart chart){

    if (this.cPanel!=null) {
        cPanel.setChart(chart);
        }
    else
        cPanel = new ChartPanel(chart, true);


    this.chartFrame.add(cPanel);
    if (this.chartFrame.isVisible() == false){
        RefineryUtilities.centerFrameOnScreen(this.chartFrame);
    }
    this.chartFrame.pack();
    this.chartFrame.setVisible(true);
}

I'd like to ask about improvement for rendering time, cause now, I stuck with this issue.


First disentangle the model and view, then you can page manageable portions of the data into view, as suggested here.

Alternatively, you might look into SlidingXYDataset, discussed here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜