谁有jfreechar用在web项目中的小例子啊,想在项目中加个工资统计图,求资料 谁有jfreechar用在web项目中的小例子啊,想在项目中加个工资统计图,求资料。发个代码看看呗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jsp中使用jfreechart还是struts2整合jfreechart,google下到处都是 要有项目代码的哦?找了一下午了。。用的ssh想jf加入jsp,不知道怎么弄,开始用ext,后面看了下做饼图还是用jf好些是吧,求大神指导 目前做图表比较简单的还是fusionchart吧 只需给它一个xml格式的String串就行 楼主可以找一个fusionchart的资料看一下 如果需要的话我可以给你部分资料跟demo 之前用fusionchart做过项目 如果是初学者,可以从jfreechart开始入手,等熟悉了再去用fusioncharts这些框架。 struts2整合jfreechart这个在struts2的文档里面都有例子,文件怎么配置需要哪些包等等。代码比较多我就不写了 在jsp上用json封装数据行么? 这跟你使用jfreechart有什么关系 大神求代码示例,要和ssh整合的哦 /** * 柱状图 * @param dataset * @param plot * @param width * @param height * @throws Exception */ public void pillar(DefaultCategoryDataset dataset, PlotOrientation plot, Integer width, Integer height) throws Exception { JFreeChart chart = ChartFactory.createBarChart3D("", "", "", dataset, plot, true, true, true); CategoryPlot plot1 = chart.getCategoryPlot();//获得图表区域对象 BarRenderer3D bar = (BarRenderer3D) plot1.getRenderer(); bar.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());//显示每个柱的数值 bar.setBaseItemLabelsVisible(true); bar.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); bar.setItemLabelAnchorOffset(-12D);// 设置柱形图上的文字偏离值 if (height == 35) { height = 135; bar.setMaximumBarWidth(0.25); bar.setItemMargin(0.000000005); } plot1.setRenderer(bar); try { NumberAxis axis = (NumberAxis) plot1.getRangeAxis();// y轴精度 axis.setAutoRangeIncludesZero(true);// 设置刻度必须从0开始 axis.setNumberFormatOverride(new DecimalFormat("#0")); } catch (Exception e) {} getResponse().setContentType("text/plain;charset=UTF-8"); ChartUtilities.writeChartAsPNG(getResponse().getOutputStream(), chart, width, height); } /** * 折线图 * @param dataset * @param plot * @param width * @param height * @throws Exception */ public void line(DefaultCategoryDataset dataset, PlotOrientation plot, Integer width, Integer height) throws Exception { JFreeChart chart = ChartFactory.createLineChart("", "", "", dataset, plot, true, true, true); CategoryPlot plot1 = chart.getCategoryPlot();//获得图表区域对象 LineAndShapeRenderer renderer = new LineAndShapeRenderer(); //renderer.setSeriesPaint(0, Color.BLUE);// 改变折线的颜色 renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());//显示每个柱的数值 renderer.setBaseItemLabelsVisible(true); renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); renderer.setItemLabelAnchorOffset(2D);// 设置柱形图上的文字偏离值 if (height == 35) { height = 135; } plot1.setRenderer(renderer);// 给折线加点 try { NumberAxis axis = (NumberAxis) plot1.getRangeAxis();// y轴精度 axis.setAutoRangeIncludesZero(true);// 设置刻度必须从0开始 axis.setNumberFormatOverride(new DecimalFormat("#0")); } catch (Exception e) {} getResponse().setContentType("text/plain;charset=UTF-8"); ChartUtilities.writeChartAsPNG(getResponse().getOutputStream(), chart, width, height); } /** * 饼图 * @param dataset * @param width * @param height * @throws Exception */ public void round(DefaultPieDataset dataset, Integer width, Integer height) throws Exception { JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, true); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelLinkMargin(0.1d); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00%"))); getResponse().setContentType("text/plain;charset=UTF-8"); ChartUtilities.writeChartAsPNG(getResponse().getOutputStream(), chart, width, height); } // 客户来源分布统计柱状图 private String originPillar() throws Exception { JSONArray array = JSONArray.fromObject(getSessionAttr(DATA_JSON)); List<Dict> origins = dictMng.getList("CUSTOMER_ORIGIN"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < array.size(); i++) { JSONObject object = (JSONObject) array.get(i); JSONArray array1 = object.getJSONArray("data"); for (int j = 0; j < array1.size(); j++) { dataset.addValue(Integer.parseInt(array1.get(j).toString().split(":")[0]), origins.get(j).getName(), object.getString("shortName")); } } pillar(dataset, PlotOrientation.VERTICAL, paramInt("width"), 350); return null; } jsp sqlserver中最好的分页 看看什么叫 回复内容太短了! !!!!!!!!!! displaytag的caption问题,急!! Eclipse使用什么来识别web项目的? 从数据库提取日期问题 jspsmartupload 中文问题,需要帮助。 急求JSP在线用户的问题,解决监听session,100分送上 jsp+asp的问题?在线等!!!!!!急急!!! 查询语句 ssh开发支持pdf浏览——在线给分 求大牛解决问题,高分送!!! jsp中用javabean类连接数据库问题. 请各位亲看看.
要有项目代码的哦?找了一下午了。。用的ssh想jf加入jsp,不知道怎么弄,开始用ext,后面看了下做饼图还是用jf好些是吧,求大神指导
在jsp上用json封装数据行么?
* 柱状图
* @param dataset
* @param plot
* @param width
* @param height
* @throws Exception
*/
public void pillar(DefaultCategoryDataset dataset, PlotOrientation plot, Integer width, Integer height) throws Exception {
JFreeChart chart = ChartFactory.createBarChart3D("", "", "", dataset, plot, true, true, true);
CategoryPlot plot1 = chart.getCategoryPlot();//获得图表区域对象
BarRenderer3D bar = (BarRenderer3D) plot1.getRenderer();
bar.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());//显示每个柱的数值
bar.setBaseItemLabelsVisible(true);
bar.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
bar.setItemLabelAnchorOffset(-12D);// 设置柱形图上的文字偏离值
if (height == 35) {
height = 135;
bar.setMaximumBarWidth(0.25);
bar.setItemMargin(0.000000005);
}
plot1.setRenderer(bar);
try {
NumberAxis axis = (NumberAxis) plot1.getRangeAxis();// y轴精度
axis.setAutoRangeIncludesZero(true);// 设置刻度必须从0开始
axis.setNumberFormatOverride(new DecimalFormat("#0"));
} catch (Exception e) {}
getResponse().setContentType("text/plain;charset=UTF-8");
ChartUtilities.writeChartAsPNG(getResponse().getOutputStream(), chart, width, height);
}
/**
* 折线图
* @param dataset
* @param plot
* @param width
* @param height
* @throws Exception
*/
public void line(DefaultCategoryDataset dataset, PlotOrientation plot, Integer width, Integer height) throws Exception {
JFreeChart chart = ChartFactory.createLineChart("", "", "", dataset, plot, true, true, true);
CategoryPlot plot1 = chart.getCategoryPlot();//获得图表区域对象
LineAndShapeRenderer renderer = new LineAndShapeRenderer();
//renderer.setSeriesPaint(0, Color.BLUE);// 改变折线的颜色
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());//显示每个柱的数值
renderer.setBaseItemLabelsVisible(true);
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
renderer.setItemLabelAnchorOffset(2D);// 设置柱形图上的文字偏离值
if (height == 35) {
height = 135;
}
plot1.setRenderer(renderer);// 给折线加点
try {
NumberAxis axis = (NumberAxis) plot1.getRangeAxis();// y轴精度
axis.setAutoRangeIncludesZero(true);// 设置刻度必须从0开始
axis.setNumberFormatOverride(new DecimalFormat("#0"));
} catch (Exception e) {}
getResponse().setContentType("text/plain;charset=UTF-8");
ChartUtilities.writeChartAsPNG(getResponse().getOutputStream(), chart, width, height);
}
/**
* 饼图
* @param dataset
* @param width
* @param height
* @throws Exception
*/
public void round(DefaultPieDataset dataset, Integer width, Integer height) throws Exception {
JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, true);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setLabelLinkMargin(0.1d);
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00%")));
getResponse().setContentType("text/plain;charset=UTF-8");
ChartUtilities.writeChartAsPNG(getResponse().getOutputStream(), chart, width, height);
}
private String originPillar() throws Exception {
JSONArray array = JSONArray.fromObject(getSessionAttr(DATA_JSON));
List<Dict> origins = dictMng.getList("CUSTOMER_ORIGIN");
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (int i = 0; i < array.size(); i++) {
JSONObject object = (JSONObject) array.get(i);
JSONArray array1 = object.getJSONArray("data");
for (int j = 0; j < array1.size(); j++) {
dataset.addValue(Integer.parseInt(array1.get(j).toString().split(":")[0]), origins.get(j).getName(), object.getString("shortName"));
}
}
pillar(dataset, PlotOrientation.VERTICAL, paramInt("width"), 350);
return null;
}