天津建设网站的公司简介,晋城手机网站建设,跳舞游戏做的广告视频网站,wordpress滑块代码此案例是用swing显示数据的。须要引入jfreechart相关包。不同版本号可能包不同样。本人用的是此案例在ssi框架下会报错#xff0c;不用框架就没问题。Java后台逻辑代码#xff1a;public class BarChart {ChartPanel frame1;public BarChart() {CategoryDataset dataset get…此案例是用swing显示数据的。须要引入jfreechart相关包。不同版本号可能包不同样。本人用的是此案例在ssi框架下会报错不用框架就没问题。Java后台逻辑代码public class BarChart {ChartPanel frame1;public BarChart() {CategoryDataset dataset getDataSet();JFreeChart chart ChartFactory.createBarChart3D(水果, // 图表标题水果种类, // 文件夹轴的显示标签数量, // 数值轴的显示标签dataset, // 数据集PlotOrientation.VERTICAL, // 图表方向水平、垂直true, // 是否显示图例(对于简单的柱状图必须是false)false, // 是否生成工具false // 是否生成URL链接);// 从这里開始CategoryPlot plot chart.getCategoryPlot();// 获取图表区域对象CategoryAxis domainAxis plot.getDomainAxis(); // 水平底部列表domainAxis.setLabelFont(new Font(黑体, Font.BOLD, 14)); // 水平底部标题domainAxis.setTickLabelFont(new Font(宋体, Font.BOLD, 12)); // 垂直标题ValueAxis rangeAxis plot.getRangeAxis();// 获取柱状rangeAxis.setLabelFont(new Font(黑体, Font.BOLD, 15));chart.getLegend().setItemFont(new Font(黑体, Font.BOLD, 15));chart.getTitle().setFont(new Font(宋体, Font.BOLD, 20));// 设置标题字体// 到这里结束尽管代码有点多但仅仅为一个目的解决汉字乱码问题frame1 new ChartPanel(chart, true); // 这里也能够用chartFrame,能够直接生成一个独立的Frame}private static CategoryDataset getDataSet() {DefaultCategoryDataset dataset new DefaultCategoryDataset();List data new ArrayList();NewsDao dao new NewsDao();ArrayList list dao.queryAll();double value 0;String rowKeysnull;String columnKeysnull;for (News news : list) {//data.add(new News(news.getNewsId(), news.getTypeId(), news//.getTitle(), news.getPublishTime(), news.getBody(), news//.getTag(), news.getAuthor(), news.getClicks(), news//.getImgUrl()));value news.getNewsId();rowKeys news.getTitle();columnKeys news.getAuthor();dataset.addValue(value, rowKeys, columnKeys);System.out.println(value rowKeys columnKeys);}//if(value!0rowKeys!nullcolumnKeys!null){//System.out.println(value rowKeys columnKeys);//dataset.addValue(value, rowKeys, columnKeys);//}//dataset.addValue(100, 北京, 苹果);//dataset.addValue(100, 上海, 苹果);//dataset.addValue(100, 广州, 苹果);//dataset.addValue(200, 北京, 梨子);//dataset.addValue(200, 上海, 梨子);//dataset.addValue(200, 广州, 梨子);//dataset.addValue(300, 北京, 葡萄);//dataset.addValue(300, 上海, 葡萄);//dataset.addValue(300, 广州, 葡萄);//dataset.addValue(400, 北京, 香蕉);//dataset.addValue(400, 上海, 香蕉);//dataset.addValue(400, 广州, 香蕉);//dataset.addValue(500, 北京, 荔枝);//dataset.addValue(500, 上海, 荔枝);//dataset.addValue(500, 广州, 荔枝);return dataset;}public ChartPanel getChartPanel() {return frame1;}public static void main(String[] args) {JFrame frame new JFrame(Java数据统计图);// frame.setLayout(new GridLayout(2,2,10,10));frame.add(new BarChart().getChartPanel()); // 加入柱形图// frame.add(new BarChart1().getChartPanel()); //加入柱形图的还有一种效果// frame.add(new PieChart().getChartPanel()); //加入饼状图// frame.add(new TimeSeriesChart().getChartPanel()); //加入折线图frame.setBounds(50, 50, 800, 600);frame.setVisible(true);}}其它类就不上代码了跟你平时连数据库一样。看张效果图[数据乱写的]Java读取数据库数据生成柱状图标签type space height time() set tor 统计图 article undefined本条技术文章来源于互联网如果无意侵犯您的权益请点击此处反馈版权投诉本文系统来源http://www.cnblogs.com/yutingliuyl/p/6852630.html