JFreeChart solution to draw a graph with a lot of data (>100) or (>1000)

不想你离开。 提交于 2019-12-24 08:23:59

问题


I have a graph with a lot of data (>100) or (>1000). Here's how JFreeChart prints the graph now.

There are only 11 data points, and each person's name should appear on the x axis, but there are ellipses in place. Is there an ideal way to print large numbers of data like this?

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:


Some options:

  • Invoke setVerticalTickLabels() on your domain axis, as shown here.

  • Invoke setCategoryLabelPositions() with the desired angle, as shown here and here.

  • Use a SlidingCategoryDataset,as shown here and in the demo.



来源:https://stackoverflow.com/questions/40199848/jfreechart-solution-to-draw-a-graph-with-a-lot-of-data-100-or-1000

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!