1

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

image

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();
}
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
traderjosh
  • 321
  • 5
  • 16

1 Answers1

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.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045