JFreeChart jfreechart-1.0.10.jar String title = m_vote.getTitle();
Font font=new Font("黑体",Font.TRUETYPE_FONT, 12);
JFreeChart chart = ChartFactory.createBarChart3D(title,
"toupiaofenlei", "shuliang", getDataset(),
PlotOrientation.VERTICAL, false, false, false);
chart.setBackgroundPaint(Color.ORANGE);
chart.setBorderVisible(true);
chart.setBorderPaint(Color.blue);
CategoryPlot plot = chart.getCategoryPlot();//获取柱体显示区域
plot.setWeight(200);
ValueAxis valueAxis = plot.getRangeAxis();
// 设置最高的一个 Item 与图片顶端的距离
valueAxis.setUpperMargin(0.15); // 设置Y轴显示整数
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelFont(font);
domainAxis.setLowerMargin(0.05);// 设置距离图片左端距离
domainAxis.setCategoryMargin(0.2);//横轴标签之间的距离20% BarRenderer3D renderer = new BarRenderer3D();
renderer.setSeriesPaint(0, new Color(0xff00));// 设置柱的颜色
renderer.setSeriesOutlinePaint(0,Color.RED);//边框为黑色
renderer.setItemMargin(0.1);//组内柱子间隔为组宽的10%
plot.setRenderer(renderer);
String filename = "";
try {
filename = ServletUtilities.saveChartAsPNG(chart, 300, 280, null,
cmsJspActionElement.getRequest().getSession());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String graphURL = cmsJspActionElement.getRequest().getContextPath()
+ "/servlet/DisplayChart?filename=" + filename;
return graphURL;
出现中文乱码,如何解决 ???
Font font=new Font("黑体",Font.TRUETYPE_FONT, 12);
JFreeChart chart = ChartFactory.createBarChart3D(title,
"toupiaofenlei", "shuliang", getDataset(),
PlotOrientation.VERTICAL, false, false, false);
chart.setBackgroundPaint(Color.ORANGE);
chart.setBorderVisible(true);
chart.setBorderPaint(Color.blue);
CategoryPlot plot = chart.getCategoryPlot();//获取柱体显示区域
plot.setWeight(200);
ValueAxis valueAxis = plot.getRangeAxis();
// 设置最高的一个 Item 与图片顶端的距离
valueAxis.setUpperMargin(0.15); // 设置Y轴显示整数
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelFont(font);
domainAxis.setLowerMargin(0.05);// 设置距离图片左端距离
domainAxis.setCategoryMargin(0.2);//横轴标签之间的距离20% BarRenderer3D renderer = new BarRenderer3D();
renderer.setSeriesPaint(0, new Color(0xff00));// 设置柱的颜色
renderer.setSeriesOutlinePaint(0,Color.RED);//边框为黑色
renderer.setItemMargin(0.1);//组内柱子间隔为组宽的10%
plot.setRenderer(renderer);
String filename = "";
try {
filename = ServletUtilities.saveChartAsPNG(chart, 300, 280, null,
cmsJspActionElement.getRequest().getSession());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String graphURL = cmsJspActionElement.getRequest().getContextPath()
+ "/servlet/DisplayChart?filename=" + filename;
return graphURL;
出现中文乱码,如何解决 ???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货