Jfreechart生成报表

莫莫水心 发布于 2014/06/29 22:01
阅读 326
收藏 0

@changwen 你好,想跟你请教个问题:


DefaultValueDataset dataset =new DefaultValueDataset(50D);

DialPlot dialplot = new DialPlot();
dialplot.setView(0.20999999999999999D, 0.0D, 0.57999999999999996D, 0.29999999999999999D);
dialplot.setDataset(dataset);
ArcDialFrame arcdialframe = new ArcDialFrame(60D, 60D);
arcdialframe.setInnerRadius(0.59999999999999998D);
arcdialframe.setOuterRadius(0.90000000000000002D);
arcdialframe.setForegroundPaint(Color.darkGray);
arcdialframe.setStroke(new BasicStroke(3F));
dialplot.setDialFrame(arcdialframe);
GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(240, 240, 240));
DialBackground dialbackground = new DialBackground(gradientpaint);
dialbackground.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
dialplot.addLayer(dialbackground);
StandardDialScale standarddialscale = new StandardDialScale(0.0D, 100D, 115D, -50D, 10D, 4);
standarddialscale.setTickRadius(0.88D);
standarddialscale.setTickLabelOffset(0.070000000000000007D);
standarddialscale.setMajorTickIncrement(25D);
dialplot.addScale(0, standarddialscale);
org.jfree.chart.plot.dial.DialPointer.Pin pin = new org.jfree.chart.plot.dial.DialPointer.Pin();
pin.setRadius(0.81999999999999995D);
dialplot.addLayer(pin);
JFreeChart jfreechart = new JFreeChart(dialplot);


jfreechart.setTitle("Dial Demo 3");

String pngPath = "D:/xxx.png";
try{
File file = new File(pngPath);
    if(!file.exists()){    
    file.getParentFile().mkdirs();
    file.createNewFile();
    }

FileOutputStream fos = null;
fos = new FileOutputStream(file);
ChartUtilities.writeChartAsPNG(fos,jfreechart, 640, 480);
fos.close();
}catch(IOException e){
throw new UncheckedException("生成报表图片失败",e);
}

生成这种仪表好像套用不起来你的Util,请问下怎么处理呢?

加载中
0
扁-哥
扁-哥
我值封装了常用的5张表,你提到的表没有涉及,你可以修改渲染修改样式。
返回顶部
顶部