本文介绍了JFreeChart解决方案绘制包含大量数据(> 100)或(> 1000)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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





只有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 ++){//迭代直到结果数组的末尾
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,假);

ChartPanel chartPanel =新ChartPanel(图表,W,H,W,H,W,H,假,真,真,真,真);
chart.setBorderVisible(true);
chartPanel.setSpaceBetweenGroupsOfBars(1);
this.add(chartPanel);
revalidate();
repaint();
}


解决方案

一些选项:


$ b

  • 在您的域轴上调用 setVerticalTickLabels(),如。


  • 调用 setCategoryLabelPositions() 与所需的角度,如和。


  • 使用 SlidingCategoryDataset ,如所示和中。



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();
}
解决方案

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.

这篇关于JFreeChart解决方案绘制包含大量数据(&gt; 100)或(&gt; 1000)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 09:02