JFreeChart与MySql

xiaoxiao2026-05-23  12

JFreeChart是JFreeChart公司在开源网站SourceForge.net上的一个项目,该公司的主要产品有如下: 1、JFreeReport:报表解决工具 2、JFreeChart:Java图形解决方案(Application/Applet/Servlet/Jsp) 3、JCommon:JFreeReport和JFreeChart的公共类库 4、JFreeDesigner:JFreeReport的报表设计工具 我们可以从jfree官方网站上获取最新版本和相关资料(但是jfree的document需要40美金才能获取), 获取地址:http://www.jfree.org/jfreechart/index.html(同时可以获得简明介绍) //图表对象JFreechart,获取图表对象的方法如下: JFreechart chart = new JFreechart(xxxxplot); JFreechart chart = ChartFactory.creatxxxxchart(…..); //各种数据集xxxxxdataset,比如 Dial 图表对应的是valueDataset数据集 //图表区域对象xxxxplot,其决定了什么样的图表,需要Axis、Reander、dataset对象的支持 如何得到一个plot:例如CategoryPlot plot = chart.getCategoryPlot(); //用于处理图表的两个轴xxxxxAxis 如何得到一个Axis:例如CategoryAxis domainAxis = plot.getDomainAxis(); //负责如何显示图表对象xxxxReander 如何得到一个reander: 例如 XYitemReander renderer = plot.getReander(); renderer.setSeriesPaint(0, new Color(0, 255, 255)); //用于生成Web图表各个项目的鼠标点击链接xxxxxURLGenerator //用于生成图像的帮助提示xxxxToolTipGenerator PiePlot3D plot = new PiePlot3D(dataset); plot.setToolTipGenerator(new StandardPieToolTipGenerator()); //还有一个很重要的类ChartUtilities用于存储作用的 ChartUtilities.saveChartAsJPEG(new File(path),0.7f, chart, 800, 600); 1.应用于数据库的dataset有: JDBCCategoryDataset、JDBCPieDataset、JDBCXYDataset 实现方法如下: public Dataset getValue(){ Connection conn = null; Statement pstmt = null; ResultSet rs=null; JDBCCategoryDataset dataset = null; String sql = "select name, num from book group by id"; try { conn = DBUtils.getConnection(); dataset=new JDBCCategoryDataset(conn); pstmt = conn.createStatement(); dataset.executeQuery(sql); return dataset; } catch (SQLException e) { System.out.println(e.toString()); } finally { DBUtils.release(rs,pstmt,conn); } return null; } Dataset dataset = getValue(); CategoryDataset set = (CategoryDataset)dataset; 相关资源:JFreeChart使用大全
转载请注明原文地址: https://www.6miu.com/read-5049267.html

最新回复(0)