jfreechart产生柱状图问题 大哥们 我在开发的时候 有个最简单的柱状图但是我在我项目中就是不能产生出最简单的柱状图,产生的都是带有一定效果的比如 有阴影 就是弄得像个圆柱不是个长方形条 这是为什么啊?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我从网上找的例子里面没有设置圆柱和阴影 然后测试发现生成的图片还是有阴影和圆柱。这还是我设置的原因吗?我把代码贴上来。public String getBarChart2D(JfreeChartVo vo,String xmlStr) { if(datset.getCategoryDataset(xmlStr)==null){ return "wrong data"; } JFreeChart chartbar = ChartFactory.createBarChart("", "", "车辆数", datset.getCategoryDataset(xmlStr), PlotOrientation.VERTICAL, true, true, false); chartbar.setTitle(new TextTitle(vo.getTitle(), new Font("黑体", Font.BOLD, 20))); CategoryPlot plot = chartbar.getCategoryPlot();// 获取图表区域对象 LegendTitle legend = chartbar.getLegend(0); legend.setItemFont(new Font("黑体", Font.TYPE1_FONT, 12)); // 显示的图例放到右边 legend.setPosition(RectangleEdge.RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); // 水平底部列表 domainAxis.setLabelFont(new Font("黑体", Font.BOLD, 10)); // 水平底部标题 domainAxis.setTickLabelFont(new Font("黑体", Font.BOLD, 10)); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // 背景板 颜色 plot.setBackgroundPaint(new Color(245,222,220)); //设置网格横线颜色 Color.decode("#799AE1") plot.setRangeGridlinePaint(Color.black); plot.setBackgroundAlpha(1f); plot.setForegroundAlpha(1.0f); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();// 获取柱状 rangeAxis.setTickMarksVisible(false); rangeAxis.setUpperMargin(0.1);//设置最高的一个柱与图片顶端的距离(最高柱的10%) rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 10)); BarRenderer customBarRenderer = (BarRenderer) plot.getRenderer(); customBarRenderer .setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值 customBarRenderer.setBaseOutlinePaint(Color.BLACK); customBarRenderer.setBaseItemLabelsVisible(true); // 注意:此句很关键,若无此句,那数字的显示会被覆盖,给人数字没有显示出来的问题 customBarRenderer .setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); customBarRenderer.setItemLabelAnchorOffset(8D);// 设置柱形图上的文字偏离值 customBarRenderer.setItemLabelsVisible(true); customBarRenderer.setMaximumBarWidth(0.1); //柱子最宽不过10%(全局) customBarRenderer.setMinimumBarLength(0.1);//柱子最窄不过5%(全局) customBarRenderer.setItemMargin(0.1);//组内柱子间隔为组宽的10% customBarRenderer.setSeriesPaint(0, new Color(60,105,225));//第一个柱子的颜色为大红 customBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);//边框为黑色 customBarRenderer.setSeriesPaint(1, new Color(0,191,255));//第二个柱子的颜色为大蓝 // BarRenderer3D renderer = new BarRenderer3D(); // renderer.setBaseItemLabelGenerator(new // StandardCategoryItemLabelGenerator("{4}",new DecimalFormat("8.0%"))); // renderer.setItemLabelFont(new Font("黑体",Font.PLAIN,12)); // renderer.setItemLabelsVisible(true); try { OutputStream os = new FileOutputStream(vo.getPath()); // 由ChartUtilities生成文件到一个体outputStream中去 ChartUtilities.writeChartAsPNG(os, chartbar, vo.getWidth(), vo .getHeight()); } catch (FileNotFoundException e) { e.printStackTrace(); return "there is a wrong path"; }catch (IOException e) { e.printStackTrace(); return "there is a IOException"; } return "OK"; } renderer.setShadowVisible(false);//是否显示阴影 解决ie6的select问题很多天,什么时候能看见日出啊~~~~ 有关hibernate的操作 表单里有多个按钮点击后我要怎么判断是哪个按钮呢 请大家帮个忙吧~~~~!!! 关于el表达式的问题,大家帮帮忙啊 jsp连接SQLServer数据库遇到的问题 请大侠帮忙指点:执行servelet时总报java.sql.SQLException: 用尽的 Resultset 如何得到当前日的前一天的日期 无法在Servlet中import 自定义的类,急! why why why? 求大神指导 请教 C3P0配置
public String getBarChart2D(JfreeChartVo vo,String xmlStr) {
if(datset.getCategoryDataset(xmlStr)==null){
return "wrong data";
}
JFreeChart chartbar = ChartFactory.createBarChart("", "", "车辆数",
datset.getCategoryDataset(xmlStr), PlotOrientation.VERTICAL, true,
true, false);
chartbar.setTitle(new TextTitle(vo.getTitle(), new Font("黑体",
Font.BOLD, 20)));
CategoryPlot plot = chartbar.getCategoryPlot();// 获取图表区域对象
LegendTitle legend = chartbar.getLegend(0);
legend.setItemFont(new Font("黑体", Font.TYPE1_FONT, 12));
// 显示的图例放到右边
legend.setPosition(RectangleEdge.RIGHT);
CategoryAxis domainAxis = plot.getDomainAxis();
// 水平底部列表
domainAxis.setLabelFont(new Font("黑体", Font.BOLD, 10));
// 水平底部标题
domainAxis.setTickLabelFont(new Font("黑体", Font.BOLD, 10));
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // 背景板 颜色
plot.setBackgroundPaint(new Color(245,222,220));
//设置网格横线颜色 Color.decode("#799AE1")
plot.setRangeGridlinePaint(Color.black); plot.setBackgroundAlpha(1f);
plot.setForegroundAlpha(1.0f); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();// 获取柱状
rangeAxis.setTickMarksVisible(false);
rangeAxis.setUpperMargin(0.1);//设置最高的一个柱与图片顶端的距离(最高柱的10%) rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 10)); BarRenderer customBarRenderer = (BarRenderer) plot.getRenderer();
customBarRenderer
.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值 customBarRenderer.setBaseOutlinePaint(Color.BLACK);
customBarRenderer.setBaseItemLabelsVisible(true); // 注意:此句很关键,若无此句,那数字的显示会被覆盖,给人数字没有显示出来的问题
customBarRenderer
.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
customBarRenderer.setItemLabelAnchorOffset(8D);// 设置柱形图上的文字偏离值
customBarRenderer.setItemLabelsVisible(true);
customBarRenderer.setMaximumBarWidth(0.1); //柱子最宽不过10%(全局)
customBarRenderer.setMinimumBarLength(0.1);//柱子最窄不过5%(全局)
customBarRenderer.setItemMargin(0.1);//组内柱子间隔为组宽的10%
customBarRenderer.setSeriesPaint(0, new Color(60,105,225));//第一个柱子的颜色为大红
customBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesPaint(1, new Color(0,191,255));//第二个柱子的颜色为大蓝
// BarRenderer3D renderer = new BarRenderer3D();
// renderer.setBaseItemLabelGenerator(new
// StandardCategoryItemLabelGenerator("{4}",new DecimalFormat("8.0%")));
// renderer.setItemLabelFont(new Font("黑体",Font.PLAIN,12));
// renderer.setItemLabelsVisible(true);
try {
OutputStream os = new FileOutputStream(vo.getPath());
// 由ChartUtilities生成文件到一个体outputStream中去
ChartUtilities.writeChartAsPNG(os, chartbar, vo.getWidth(), vo
.getHeight()); } catch (FileNotFoundException e) {
e.printStackTrace();
return "there is a wrong path";
}catch (IOException e) {
e.printStackTrace();
return "there is a IOException";
}
return "OK";
}