- 浏览: 752989 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
lgh1992314:
a offset: 26b offset: 24c offse ...
java jvm字节占用空间分析 -
ls0609:
语音实现在线听书http://blog.csdn.net/ls ...
Android 语音输入API使用 -
wangli61289:
http://viralpatel-net-tutorials ...
Android 语音输入API使用 -
zxjlwt:
学习了素人派http://surenpi.com
velocity宏加载顺序 -
tt5753:
谢啦........
Lucene的IndexWriter初始化时的LockObtainFailedException的解决方法
jfreechart版本:0.9.20
把下面三个类放一起就可以编译,可以查看各种图生成的效果。
ChartFrame.java有错
把下面三个类放一起就可以编译,可以查看各种图生成的效果。
ChartFrame.java有错
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import org.jfree.chart.JFreeChart; /** */ /** * @author xum @ 2006/09/14 neusoft * TODO To change the template for this * generated type comment go to Window - Preferences - Java - Code Style * - Code Templates */ public class ChartFrame extends JFrame { /** * */ public ChartFrame() { this.setBounds((int) ((1024 - 800) / 2), (int) ((768 - 600) / 2), 800, 600); this.setTitle("JFreeChart Demo"); JFreeChart Chart = null; //Chart = ChartCreater.createCategoryChart(); // Chart = ChartCreater.createCategoryChart3D(); // Chart = ChartCreater.createBarChart(); // Chart = ChartCreater.createBarChart3D(); // Chart = ChartCreater.createAreaChart(); // Chart = ChartCreater.createHistogram(); // Chart = ChartCreater.createLintChart3D(); // Chart = ChartCreater.createMultiplePieChart(); //Chart = ChartCreater.createMultiplePieChart3D(); // Chart = ChartCreater.createPieChart(); //Chart = ChartCreater.createPieChart3D(); // Chart = ChartCreater.createRingChart(); Chart = ChartCreater.createScatterPlot(); // Chart = ChartCreater.createBubbleChart(); //youcuo // Chart = ChartCreater.createCandlestickChart(); //youcuo // Chart = ChartCreater.createCombinedChart(); // Chart = ChartCreater.createGanttChart(); // Chart = ChartCreater.createHighLowChart(); //youcuo // Chart = ChartCreater.createStackedAreaChart(); // Chart = ChartCreater.createStackedBarChart(); // Chart = ChartCreater.createStackedBarChart3D(); // Chart = ChartCreater.createStackedCategoryChart(); // Chart = ChartCreater.createStackedCategoryChart3D(); // Chart = ChartCreater.createStackedXYAreaChart(); //youcuo // Chart = ChartCreater.createWaterfallChart(); // Chart = ChartCreater.createXYAreaChart(); // Chart = ChartCreater.createXYBarChart(); // Chart = ChartCreater.createXYLineChart(); // Chart = ChartCreater.createXYStepAreaChart(); // Chart = ChartCreater.createXYStepChart(); Chart.getPlot().setBackgroundAlpha(1.0f); Chart.getPlot().setNoDataMessage("当前没有有效的数据"); Image chart = Chart.createBufferedImage(700, 500); JLabel label = new JLabel(); label.setIcon(new ImageIcon(chart)); this.getContentPane().add(label, BorderLayout.CENTER); } public static void main(String[] args) { new ChartFrame().setVisible(true); } }
import java.util.Calendar; import java.util.Date; import org.jfree.chart.*; import org.jfree.data.CategoryDataset; import org.jfree.data.DefaultCategoryDataset; import org.jfree.data.DefaultHighLowDataset; import org.jfree.data.DefaultPieDataset; import org.jfree.data.DefaultTableXYDataset; import org.jfree.data.HighLowDataset; import org.jfree.data.IntervalCategoryDataset; import org.jfree.data.OHLCDataItem; import org.jfree.data.PieDataset; import org.jfree.data.XYSeries; import org.jfree.data.XYSeriesCollection; import org.jfree.data.gantt.Task; import org.jfree.data.gantt.TaskSeries; import org.jfree.data.gantt.TaskSeriesCollection; import org.jfree.data.time.SimpleTimePeriod; /** */ /** * @author xum @ 2006/09/14 JFreeChart 数据集样例 * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class ChartDataSet { private static final String series1 = "series1"; private static final String series2 = "series2"; private static final String series3 = "series3"; private static final String category1 = "category1"; private static final String category2 = "category2"; private static final String category3 = "category3"; private static final String category4 = "category4"; private static final String category5 = "category5"; /** */ /** * CategoryDataset 支持图表类型 BarChart BarChart3D LineChart LintChart3D * AreaChart WaterfallChart MultiplePieChart MultiplePieChart3D * StackedBarChart StackedBarChart3D StackedAreaChart * * @return CategoryDataset */ public static CategoryDataset createCategoryDataset() { DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); categoryDataset.addValue(2.0, series1, category1); categoryDataset.addValue(4.0, series1, category2); categoryDataset.addValue(3.0, series1, category3); categoryDataset.addValue(7.0, series1, category4); categoryDataset.addValue(5.0, series1, category5); categoryDataset.addValue(5.0, series2, category1); categoryDataset.addValue(9.0, series2, category2); categoryDataset.addValue(6.0, series2, category3); categoryDataset.addValue(5.0, series2, category4); categoryDataset.addValue(2.0, series2, category5); categoryDataset.addValue(6.5, series3, category1); categoryDataset.addValue(7.5, series3, category2); categoryDataset.addValue(4.0, series3, category3); categoryDataset.addValue(8.0, series3, category4); categoryDataset.addValue(9.0, series3, category5); return categoryDataset; } /** */ /** * XYSeriesCollection 支持图表类型 PolarChart XYBarChart XYLineChart * XYStepAreaChart XYAreaChart XYStepChart Histogram ScatterPlot * * @return XYSeriesCollection */ public static XYSeriesCollection createXYSeriesCollection() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries xyseries1 = new XYSeries(series1); XYSeries xyseries2 = new XYSeries(series2); XYSeries xyseries3 = new XYSeries(series3); xyseries1.add(2.5, 6.0); xyseries1.add(4.0, 3.5); xyseries1.add(7.5, 5.5); xyseries1.add(12.0, 7.0); xyseries1.add(9.5, 10.0); xyseries2.add(4.5, 11.0); xyseries2.add(6.0, 3.5); xyseries2.add(2.5, 5.0); xyseries2.add(3.5, 6.5); xyseries2.add(5.0, 7.0); xyseries3.add(7.0, 12.0); xyseries3.add(4.5, 8.0); xyseries3.add(6.0, 4.5); xyseries3.add(9.5, 11.0); xyseries3.add(3.0, 6.0); dataset.addSeries(xyseries1); dataset.addSeries(xyseries2); dataset.addSeries(xyseries3); return dataset; } /** */ /** * DefaultTableXYDataset 支持图表类型 StackedXYAreaChart * * @return DefaultTableXYDataset */ public static DefaultTableXYDataset createDefaultTableXYDataset() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries xyseries1 = new XYSeries(series1); XYSeries xyseries2 = new XYSeries(series2); XYSeries xyseries3 = new XYSeries(series3); xyseries1.add(2.5, 6.0); xyseries1.add(4.0, 3.5); xyseries1.add(7.5, 5.5); xyseries1.add(12.0, 7.0); xyseries1.add(9.5, 10.0); xyseries2.add(4.5, 11.0); xyseries2.add(6.0, 3.5); xyseries2.add(2.5, 5.0); xyseries2.add(3.5, 6.5); xyseries2.add(5.0, 7.0); xyseries3.add(7.0, 12.0); xyseries3.add(4.5, 8.0); xyseries3.add(6.0, 4.5); xyseries3.add(9.5, 11.0); xyseries3.add(3.0, 6.0); dataset.addSeries(xyseries1); dataset.addSeries(xyseries2); dataset.addSeries(xyseries3); return dataset; } /** */ /** * PieDataset 支持图表类型 PieChart PieChart3D RingChart * * @return PieDataset */ public static PieDataset createPieDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(category1, 12.0); dataset.setValue(category2, 2.0); dataset.setValue(category3, 4.0); dataset.setValue(category4, 20.0); dataset.setValue(category5, 7.0); return dataset; } /** */ /** * IntervalCategoryDataset 支持图表类型 GanttChart * * @return IntervalCategoryDataset */ public static IntervalCategoryDataset createGanttDataset() { TaskSeriesCollection taskSeriesCollection = new TaskSeriesCollection(); TaskSeries s1 = new TaskSeries("Scheduled"); s1.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)))); s1.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)))); s1.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)))); s1.add(new Task("Design Phase", new SimpleTimePeriod(date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)))); s1.add(new Task("Design Signoff", new SimpleTimePeriod(date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001)))); s1.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001)))); s1.add(new Task("Design Review", new SimpleTimePeriod(date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001)))); s1.add(new Task("Revised Design Signoff", new SimpleTimePeriod(date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001)))); s1.add(new Task("Beta Implementation", new SimpleTimePeriod(date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001)))); s1.add(new Task("Testing", new SimpleTimePeriod(date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001)))); s1.add(new Task("Final Implementation", new SimpleTimePeriod(date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001)))); s1.add(new Task("Signoff", new SimpleTimePeriod(date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001)))); TaskSeries s2 = new TaskSeries("Actual"); s2.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)))); s2.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)))); s2.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(15, Calendar.MAY, 2001)))); s2.add(new Task("Design Phase", new SimpleTimePeriod(date(15, Calendar.MAY, 2001), date(17, Calendar.JUNE, 2001)))); s2.add(new Task("Design Signoff", new SimpleTimePeriod(date(30, Calendar.JUNE, 2001), date(30, Calendar.JUNE, 2001)))); s2.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(1, Calendar.JULY, 2001), date(12, Calendar.SEPTEMBER, 2001)))); s2 .add(new Task("Design Review", new SimpleTimePeriod(date(12, Calendar.SEPTEMBER, 2001), date(22, Calendar.SEPTEMBER, 2001)))); s2 .add(new Task("Revised Design Signoff", new SimpleTimePeriod( date(25, Calendar.SEPTEMBER, 2001), date(27, Calendar.SEPTEMBER, 2001)))); s2.add(new Task("Beta Implementation", new SimpleTimePeriod(date(27, Calendar.SEPTEMBER, 2001), date(30, Calendar.OCTOBER, 2001)))); s2.add(new Task("Testing", new SimpleTimePeriod(date(31, Calendar.OCTOBER, 2001), date(17, Calendar.NOVEMBER, 2001)))); s2.add(new Task("Final Implementation", new SimpleTimePeriod(date(18, Calendar.NOVEMBER, 2001), date(5, Calendar.DECEMBER, 2001)))); s2.add(new Task("Signoff", new SimpleTimePeriod(date(10, Calendar.DECEMBER, 2001), date(11, Calendar.DECEMBER, 2001)))); taskSeriesCollection.add(s1); taskSeriesCollection.add(s2); return taskSeriesCollection; } /** */ /** * DefaultOHLCDataset 支持的图表类型 HighLowChart CandlestickChart * * @return DefaultOHLCDataset */ public static DefaultHighLowDataset createDefaultOHLCDataset() { OHLCDataItem[] data = new OHLCDataItem[10]; data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0); data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0); data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0); data[3] = new OHLCDataItem(new Date(25L), 2.0, 4.0, 1.0, 3.0, 100.0); data[4] = new OHLCDataItem(new Date(47L), 4.0, 9.0, 2.0, 5.0, 120.0); data[5] = new OHLCDataItem(new Date(58L), 3.0, 7.0, 3.0, 6.0, 140.0); data[6] = new OHLCDataItem(new Date(60L), 2.0, 4.0, 1.0, 3.0, 100.0); data[7] = new OHLCDataItem(new Date(44L), 4.0, 9.0, 2.0, 5.0, 120.0); data[8] = new OHLCDataItem(new Date(38L), 3.0, 7.0, 3.0, 6.0, 140.0); data[9] = new OHLCDataItem(new Date(40L), 3.0, 7.0, 3.0, 6.0, 140.0); HighLowDataset defaultHighLowDataset = new DefaultHighLowDataset(null, null, null, null, null, null, null); return (DefaultHighLowDataset) defaultHighLowDataset; } /** */ /** * DefaultXYZDataset 支持图表类型 BubbleChart * * @return DefaultXYZDataset */ public static DefaultCategoryDataset createDefaultXYZDataset() { DefaultCategoryDataset defaultXYZDataset = new DefaultCategoryDataset(); double[] x1 = new double[] { 1.0, 2.0, 3.0 }; double[] y1 = new double[] { 4.0, 5.0, 6.0 }; double[] z1 = new double[] { 7.0, 8.0, 9.0 }; double[][] data1 = new double[][] { x1, y1, z1 }; //defaultXYZDataset.addSeries(series1, data1); double[] x2 = new double[] { 1.0, 2.0, 3.0 }; double[] y2 = new double[] { 4.0, 5.0, 6.0 }; double[] z2 = new double[] { 7.0, 8.0, 9.0 }; double[][] data2 = new double[][] { x2, y2, z2 }; //defaultXYZDataset.addSeries(series1, data2); return defaultXYZDataset; } private static Date date(int day, int month, int year) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); Date result = calendar.getTime(); return result; } }
import java.awt.Color; import java.awt.Font; import java.awt.Rectangle; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.labels.PieToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.BarRenderer; import org.jfree.chart.renderer.LineAndShapeRenderer; import org.jfree.chart.renderer.XYItemRenderer; import org.jfree.data.CombinedDataset; import org.jfree.data.XYZDataset; import org.jfree.util.TableOrder; /** */ /** * @author xum @ 2006/09/14 neusoft TODO To change the template for this * generated type comment go to Window - Preferences - Java - Code Style * - Code Templates */ public class ChartCreater { /** */ /** * 2D柱图 * * @return */ public static JFreeChart createCategoryChart() { JFreeChart chart = ChartFactory.createBarChart("Bar2D", // 图表名称 "Category", // X轴名称 "Value", // Y轴名称 ChartDataSet.createCategoryDataset(), PlotOrientation.VERTICAL, // 图表方向 true, // 图例 true, // Tooltips false); // URL CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /** */ /** * 3D柱图 * * @return */ public static JFreeChart createCategoryChart3D() { JFreeChart chart = ChartFactory.createBarChart3D("Bar2D", "Category", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /** */ /** * 2D条形图 * * @return */ public static JFreeChart createBarChart() { JFreeChart chart = ChartFactory.createBarChart("Bar2D", "Category", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); return chart; } /** */ /** * 3D条形图 * * @return */ public static JFreeChart createBarChart3D() { JFreeChart chart = ChartFactory.createBarChart3D("Bar2D", "Category", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); return chart; } /** */ /** * 2D线图 * * @return */ public static JFreeChart createLintChart() { JFreeChart chart = ChartFactory.createLineChart("Bar2D", "Category", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); LineAndShapeRenderer lineAndShapeRenderer = (LineAndShapeRenderer) plot .getRenderer(); lineAndShapeRenderer.setItemLabelsVisible(true); lineAndShapeRenderer.setShapesFilled(true); return chart; } /** */ /** * 3D线图 * * @return */ public static JFreeChart createLintChart3D() { JFreeChart chart = ChartFactory.createBarChart3D("Bar2D", "Category", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /** */ /** * 面积图 * * @return */ public static JFreeChart createAreaChart() { JFreeChart chart = ChartFactory.createAreaChart("Area", "Category", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /** */ /** * 瀑布图 * * @return */ public static JFreeChart createWaterfallChart() { JFreeChart chart = ChartFactory.createWaterfallChart("WaterfallChart", "Category", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /** */ /** * 2D饼图 * * @return */ public static JFreeChart createPieChart() { JFreeChart chart = ChartFactory.createPieChart("PieChart", ChartDataSet .createPieDataset(), true, true, false); PiePlot piePlot = (PiePlot) chart.getPlot(); piePlot.setCircular(false); piePlot.setLabelGap(0.02); return chart; } /** */ /** * 3D饼图 * * @return */ public static JFreeChart createPieChart3D() { JFreeChart chart = ChartFactory.createPieChart3D("PieChart3D", ChartDataSet.createPieDataset(), true, true, false); PiePlot piePlot = (PiePlot) chart.getPlot(); piePlot.setCircular(false); piePlot.setLabelGap(0.02); return chart; } /** */ /** * 复合饼图 12 */ public static JFreeChart createMultiplePieChart() { TableOrder order = TableOrder.BY_ROW; // TableOrder order = TableOrder.BY_COLUMN; JFreeChart chart = ChartFactory.createMultiplePieChart( "MultiplePieChart", ChartDataSet.createCategoryDataset(), order, true, true, false); return chart; } /** */ /** * 复合饼图3D 12 */ public static JFreeChart createMultiplePieChart3D() { TableOrder order = TableOrder.BY_ROW; // TableOrder order = TableOrder.BY_COLUMN; JFreeChart chart = ChartFactory.createMultiplePieChart3D( "MultiplePieChart3D", ChartDataSet.createCategoryDataset(), order, true, true, false); return chart; } /** */ /** * 环形图 */ public static JFreeChart createRingChart() { JFreeChart chart = ChartFactory.createPieChart("RingChart", ChartDataSet.createPieDataset(), true, true, false); Plot ringPlot = (Plot) chart.getPlot(); ringPlot.setBackgroundAlpha(1.0f); ((PiePlot) ringPlot).setCircular(false); ((PiePlot) ringPlot).setLabelGap(0.02); return chart; } /** */ /** * 散点图 40 */ public static JFreeChart createScatterPlot() { JFreeChart chart = ChartFactory.createScatterPlot("ScatterPlot", "Categary", "Value", ChartDataSet.createXYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); return chart; } /** */ /** * 组织图 */ public static JFreeChart createHistogram() { JFreeChart chart = ChartFactory.createHistogram("Histogram", "Categary", "Value", ChartDataSet.createXYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); return chart; } /** */ /** * 数据点阶梯图 33 */ public static JFreeChart createXYStepChart() { JFreeChart chart = ChartFactory.createXYStepChart("XYStepChart", "Categary", "Value", ChartDataSet.createXYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); return chart; } /**//* * 堆积柱状图 01 */ public static JFreeChart createStackedCategoryChart() { JFreeChart chart = ChartFactory.createStackedBarChart( "StackedCategoryChar", "Categary", "Value", ChartDataSet .createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /**//* * 堆积柱状图3D 04 */ public static JFreeChart createStackedCategoryChart3D() { JFreeChart chart = ChartFactory.createStackedBarChart3D( "StackedCategoryChar3D", "Categary", "Value", ChartDataSet .createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /**//* * 堆积条形图 21 */ public static JFreeChart createStackedBarChart() { JFreeChart chart = ChartFactory.createStackedBarChart( "StackedBarChart", "Categary", "Value", ChartDataSet .createCategoryDataset(), PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); return chart; } /**//* * 堆积条形图3D 23 */ public static JFreeChart createStackedBarChart3D() { JFreeChart chart = ChartFactory.createStackedBarChart3D( "StackedBarChart3D", "Categary", "Value", ChartDataSet .createCategoryDataset(), PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); return chart; } /**//* * 堆积面积图 53 */ public static JFreeChart createStackedAreaChart() { JFreeChart chart = ChartFactory.createStackedAreaChart( "StackedAreaChart", "Categary", "Value", ChartDataSet .createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /**//* * XY数据点面积图 52 */ public static JFreeChart createXYAreaChart() { JFreeChart chart = ChartFactory.createXYAreaChart("XYAreaChart", "Categary", "Value", ChartDataSet.createXYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); return chart; } /**//* * XY数据点阶梯面积图 51 */ public static JFreeChart createXYStepAreaChart() { JFreeChart chart = ChartFactory.createXYStepAreaChart( "XYStepAreaChart", "Categary", "Value", ChartDataSet .createXYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); return chart; } /**//* * XY数据点折线图 32 */ public static JFreeChart createXYLineChart() { JFreeChart chart = ChartFactory.createXYLineChart("XYLineChart", "Categary", "Value", ChartDataSet.createXYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); XYItemRenderer lineAndShapeRenderer = (XYItemRenderer) xyPlot .getRenderer(); return chart; } /**//* * XY数据点柱状图 05 */ public static JFreeChart createXYBarChart() { JFreeChart chart = ChartFactory.createXYBarChart("XYBarChart", "Categary", true, "Value", ChartDataSet .createXYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); return chart; } /**//* * 气泡图 */ public static JFreeChart createBubbleChart() { JFreeChart chart = ChartFactory.createBubbleChart("BubbleChart", "Categary", "Value", (XYZDataset) ChartDataSet.createDefaultXYZDataset(), PlotOrientation.VERTICAL, true, true, false); return chart; } /**//* * 数据点堆积面积图 */ public static JFreeChart createStackedXYAreaChart() { JFreeChart chart = ChartFactory.createStackedXYAreaChart( "StackedXYAreaChart", "Categary", "Value", ChartDataSet .createDefaultTableXYDataset(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = chart.getXYPlot(); setXYSeriesPlot(xyPlot); return chart; } /**//* * 甘特图 */ public static JFreeChart createGanttChart() { JFreeChart chart = ChartFactory.createGanttChart("GanttChart", "Categary", "Value", ChartDataSet.createGanttDataset(), true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); return chart; } /**//* * 股价图 */ public static JFreeChart createHighLowChart() { JFreeChart chart = ChartFactory.createHighLowChart("HighLowChart", "Categary", "Value", ChartDataSet.createDefaultOHLCDataset(), false); return chart; } /**//* * 烛台图 */ public static JFreeChart createCandlestickChart() { JFreeChart chart = ChartFactory.createCandlestickChart( "CandlestickChart", "Categary", "Value", ChartDataSet .createDefaultOHLCDataset(), false); return chart; } /**//* * 雷达图 */ private JFreeChart createPolarChart() { JFreeChart chart = ChartFactory.createPolarChart("PolarChart", ChartDataSet.createXYSeriesCollection(), true, true, false); return chart; } /**//* * 2D柱线图 */ public static JFreeChart createCombinedChart() { JFreeChart chart = ChartFactory.createBarChart("CombinedChart", "Categary", "Value", ChartDataSet.createCategoryDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); setCategoryPlot(plot); BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); barRenderer.setMaxBarWidth(0.10D); barRenderer.setItemMargin(0.10D); NumberAxis numberAxis = new NumberAxis(""); plot.setRangeAxis(1, numberAxis); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, ChartDataSet.createCategoryDataset()); plot.setRenderer(1, new LineAndShapeRenderer()); plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 1); return chart; } /** */ /** * 设置CategoryPlot 坐标轴及网格属性设置 * * @param plot */ private static void setCategoryPlot(CategoryPlot plot) { plot.getDomainAxis().setVisible(true); plot.getDomainAxis().setLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getDomainAxis().setLabelPaint(Color.BLACK); plot.getDomainAxis().setTickLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getDomainAxis().setTickLabelPaint(Color.BLACK); plot.getDomainAxis().setTickLabelsVisible(true); plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getRangeAxis().setLabelPaint(Color.BLACK); plot.getRangeAxis().setTickLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getRangeAxis().setTickLabelPaint(Color.BLACK); plot.getRangeAxis().setVerticalTickLabels(false); plot.getRangeAxis().setLabelAngle(0.0D); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); } /** */ /** * 设置 XYPlot * * @param plot */ private static void setXYSeriesPlot(XYPlot plot) { plot.getDomainAxis().setVisible(true); plot.getDomainAxis().setLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getDomainAxis().setLabelPaint(Color.BLACK); plot.getDomainAxis().setTickLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getDomainAxis().setTickLabelPaint(Color.BLACK); plot.getDomainAxis().setTickLabelsVisible(true); plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getRangeAxis().setLabelPaint(Color.BLACK); plot.getRangeAxis().setTickLabelFont(new Font("宋体", Font.PLAIN, 12)); plot.getRangeAxis().setTickLabelPaint(Color.BLACK); plot.getRangeAxis().setVerticalTickLabels(false); plot.getRangeAxis().setLabelAngle(0.0D); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); } }
发表评论
-
对字符串进行验证之前先进行规范化
2013-09-17 23:18 13947对字符串进行验证之前先进行规范化 应用系统中经常对字 ... -
使用telnet连接到基于spring的应用上执行容器中的bean的任意方法
2013-08-08 09:17 1469使用telnet连接到基于spring的应用上执行容器中 ... -
jdk7和8的一些新特性介绍
2013-07-06 16:07 10108更多ppt内容请查看:htt ... -
java对于接口和抽象类的代理实现,不需要有具体实现类
2013-06-12 09:50 2951原文链接:http://www.javaarch.net/j ... -
Java EE 7中对WebSocket 1.0的支持
2013-06-05 09:27 3836原文链接:http://www.javaarch.n ... -
Java Web使用swfobject调用flex图表
2013-05-28 19:05 1120Java Web使用swfobject调用 ... -
spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
2013-05-21 15:57 3330spring使用PropertyPlaceholderCon ... -
java国际化
2013-05-20 20:57 4471java国际化 本文来自:http://www.j ... -
RSS feeds with Java
2013-05-20 20:52 1213RSS feeds with Java 原文来自:htt ... -
使用ibatis将数据库从oracle迁移到mysql的几个修改点
2013-04-29 10:40 1674我们项目在公司的大战略下需要从oracle ... -
线上机器jvm dump分析脚本
2013-04-19 10:48 2903#!/bin/sh DUMP_PIDS=`p ... -
eclipse远程部署,静态文件实时同步插件
2013-04-06 20:18 5459eclipse 远程文件实时同步,eclipse远程 ... -
java价格处理的一个问题
2013-03-26 21:21 1827我们经常会处理一些价格,比如从运营上传的文件中将某 ... -
java 服务降级开关设计思路
2013-03-23 16:35 3763java 服务屏蔽开关系统,可以手工降级服务,关闭服 ... -
poi解析excel内存溢出
2013-03-20 22:21 6396真是悲剧啊,一个破内部使用系统20多个人使用的后 ... -
简单web安全框架
2013-03-16 11:56 1543web安全框架,主要用servlet filter方 ... -
基于servlet的简单的页面缓存框架
2013-03-11 19:27 1215基于servlet的页面级缓存框架的基本用法: 代码参考: ... -
Eclipse使用过程中出现java.lang.NoClassDefFoundError的解决方案
2013-02-01 17:22 1570如果jdk,classpath设置正确,突然在eclipse ... -
jetty对于包的加载顺序的处理
2013-01-28 22:58 41281.问题 今天在本地和测试环境用jet ... -
hsqldb源码分析系列6之事务处理
2013-01-20 15:20 1706在session的 public Result ...
相关推荐
jfreechart生成各种图表 柱状 饼状 折线 锥状
学习如何使用JFreeChart生成静态图表,包括设置图表的各个元素,如标题、图例、轴标签等。此外,还会涉及如何保存图表为图片文件,以便在Web页面上展示。 4. **第四章:动态图表** 本章重点在于如何实现在Web环境...
传统的一些以软件包形式发布应用程序例如报表系统等都在逐渐搬到因特网上。但是这两者之间有着天壤之别,虽然对于数据获取、业务处理等方面...因此我们下面将介绍一个JAVA的图表引擎JFreeChart用来产生基于WEB的图表。
### JFreeChart 典型图表生成及属性设置详解 JFreeChart是一款强大的开源Java图表库,用于在Java应用程序中创建各种统计图表。它支持多种类型的图表,如条形图、线图、饼图、散点图等,并且具有丰富的自定义选项。...
JFreeChart可生成饼图(pie charts)、柱状图(bar charts)、 散点图(scatter plots)、时序图(time series)、甘特图(Gantt charts)等等多种图表,并且可以产生 PNG和JPEG格式的输出,还可以与PDF和EXCEL...
首先,JFreeChart的核心功能是生成各种类型的图表,如: 1. **饼形图(Pie Chart)**:饼形图是一种将数据以扇形比例展示的图表,每个扇区代表一个类别,面积大小表示该类别的相对比例。在`jfreecharttest1.jpg`和`...
标题“Spring+JFreeChart 自动生成统计图”涉及的是在Java开发环境中,利用Spring框架和JFreeChart库来动态生成图表的技巧。这篇文章可能是介绍如何在Spring应用中集成JFreeChart,以便为数据可视化提供服务。 ...
JFreeChart的核心是`ChartFactory`类,它提供了创建各种图表类型的方法。例如,`createBarChart()`用于创建柱状图,`createPieChart()`用于创建饼状图,而`createLineChart()`则用于创建线状图。这些方法通常需要四...
这些示例展示了如何创建和定制各种图表,是学习和理解JFreeChart的绝佳资源。例如,`DemoCharts.java`包含了各种图表的基本用法,而`ChartCustomization.java`展示了如何自定义图表的样式。 ### 6. **应用场景** ...
在Java Web开发中,JSP(JavaServer Pages)是一种用于创建动态网页的技术,而JFreeChart和IText是两个强大的库,分别用于生成各种图表和PDF文档。本篇将详细介绍如何利用JSP结合这两个库来实现数据可视化和文档生成...
JFreeChart 是一个开源的 Java 库,它提供了一种在 Java 应用程序和 Web 应用程序中生成高质量图表的方法。这个库广泛用于数据可视化,支持多种图表类型,如柱状图、饼图、线图、散点图、甘特图以及组合图等。...
在描述中提到,我们还会用到JFreeChart库,这是一个用于生成各种图表的Java库,支持多种图表类型,包括柱状图和饼图。JFreeChart的强大之处在于它的灵活性,可以定制图表的颜色、样式、数据标签等各个方面。在本示例...
JFreeChart是一款强大的Java图表库,它为开发者提供了在Java应用程序和Web应用中创建各种静态、动态和交互式图表的功能。这个"jfreechart-1.0.19demo源码"是JFreeChart库的一个特定版本——1.0.19的演示代码集合,...
JFreeChart 是一个流行的 Java 图形库,提供了生成各种类型的图表,包括 SVG 图形。JFreeChart 提供了一个名为 `JFreeSVG` 的类,该类用于生成 SVG 图形。 使用 JFreeChart 生成 SVG 图表非常简单,只需要创建一个 ...
总结,JFreeChart 是一个强大且灵活的 Java 图表库,它能够帮助开发者轻松地在Servlet中创建各种图表,并且支持在网页上实现交互功能。通过深入理解 JFreeChart 的核心概念和实践,你可以提升数据可视化的质量和用户...
在JavaFX中,JFreeChart是一个非常有用的库,它允许开发者创建各种复杂的图表,如折线图、柱状图、饼图、散点图等。本文将深入探讨如何结合JavaFX与JFreeChart来实现图表的生成。 首先,我们需要了解JFreeChart库的...
JFreeChart是一款强大的Java库,用于创建各种类型的图表,包括柱状图、饼图、线图、散点图等。在“JFreeChart混合图表演示”中,我们重点探讨如何利用JFreeChart来创建一个包含多种图表类型的混合图表,以提供更丰富...
JFreeChart是一款强大的Java库,用于创建各种类型的高质量图表,如饼图、柱状图、时间序列图等。这个例子的压缩包“JFreeChart生成图表的例子.rar”包含了一些示例代码,帮助开发者理解如何利用JFreeChart在Java应用...
JFreeChart是开放源代码站点SourceForge.net上的一个JAVA项目,它主要用来各种各样的图表,这些图表包括:饼图、柱状图(普通柱状图以及堆栈柱状图)、线图、区域图、分布图、混合图、甘特图以及一些仪表盘等等。...