JFreeChart解决方案,用于绘制包含大量数据(> 100)或(> 1000)的图表

时间:2016-10-23 05:27:00

标签: java swing graph jfreechart

我有一个包含大量数据(> 100)或(> 1000)的图表。以下是JFreeChart现在如何打印图表。

image

只有11个数据点,每个人的名字应该出现在x轴上,但是有椭圆形。是否有理想的方式来打印这样的大量数据?

public void barchartResults(ArrayList<Person> results, String testName) {
    int i;
    setLayout(new FlowLayout(FlowLayout.LEFT, 20, 20));
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    String test = results.get(0).getTrait();

    for (i = 0; i < results.size(); i ++) { // Iterate until the end of the results array
        dataset.setValue(results.get(i).getScore(), results.get(i).getTrait(), results.get(i).getName());
    }

    JFreeChart chart = ChartFactory.createBarChart3D( testName + ": " + test,
            "Examinees", "Score", dataset, PlotOrientation.VERTICAL, true, true, false );

    ChartPanel chartPanel = new ChartPanel(chart, W, H, W, H, W, H, false, true, true, true, true, true); 
    chart.setBorderVisible(true);
    chartPanel.setSpaceBetweenGroupsOfBars(1);
    this.add(chartPanel);
    revalidate();
    repaint();
}

1 个答案:

答案 0 :(得分:1)

一些选项:

  • 在您的域名轴上调用setVerticalTickLabels(),如图here所示。

  • 使用所需的角度调用setCategoryLabelPositions(),如herehere所示。

  • 使用SlidingCategoryDataset,如heredemo所示。