当前位置: 代码迷 >> Java Web开发 >> JFreeChart,
  详细解决方案

JFreeChart,

热度:307   发布时间:2016-04-17 00:51:02.0
JFreeChart高手进,急!
public class TestBar3D {
private static CategoryDataset createDataset() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(0.50D, "s1", "c1");
dataset.addValue(0.00D, "s2", "c1");
dataset.addValue(-1.00D, "s3", "c1");

  dataset.addValue(1.20D, "s4", "c2");
dataset.addValue(1.40D, "s5", "c2");
dataset.addValue(-0.8D, "s6", "c2");

dataset.addValue(-1.20D, "s7", "c3");
dataset.addValue(0.40D, "s8", "c3");
dataset.addValue(-0.1D, "s9", "c3");
dataset.addValue(-0.20D, "s10", "c3");
dataset.addValue(0.80D, "s11", "c3");
dataset.addValue(1.1D, "s12", "c3");

dataset.addValue(-0.50D, "s13", "c4");
dataset.addValue(0.80D, "s14", "c4");
dataset.addValue(1.8D, "s15", "c4");
dataset.addValue(-1.5D, "s16", "c4");
dataset.addValue(-0.8D, "s17", "c4");

dataset.addValue(0.30D, "s18", "c5");
dataset.addValue(0.80D, "s19", "c5");
dataset.addValue(1.00D, "s20", "c5");
dataset.addValue(-0.8D, "s21", "c5");
return dataset;
}

public static JFreeChart createJFreeChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart3D(
"t", "ss", "vv", dataset,
PlotOrientation.VERTICAL, true, true, false);
return chart;
}

public static void main(String args[]) {
JFreeChart chart = createJFreeChart(createDataset());
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File("d:/1.jpg"));
ChartUtilities.writeChartAsJPEG(fos, chart, 1024, 768);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}

}
}

问题:因为在每个分类里面都默认有s1-s21根柱子,但是有很多是不能显示出来的,可是能够显示的柱子却被压缩的非常扁,有没有解决方法!

------解决方案--------------------
http://blog.csdn.net/jinchun1234/archive/2009/06/18/4275325.aspx
------解决方案--------------------
探讨
http://blog.csdn.net/jinchun1234/archive/2009/06/18/4275325.aspx