List of usage examples for org.jfree.chart JFreeChart getPlot
public Plot getPlot()
From source file:br.com.ifpb.models.Grafico.java
/** * /*from w ww . jav a2s. c o m*/ * @param nome * @param valor * @param tituloGrafico * @param transparencia * @param tipo * @return */ private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico, float transparencia, String tipo) { DefaultPieDataset data = new DefaultPieDataset(); for (int i = 0; i < nome.toArray().length; i++) { data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString())); } JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true); java.awt.Color cor = new java.awt.Color(200, 200, 200); chart.setBackgroundPaint(cor); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setLabelLinksVisible(true); plot.setNoDataMessage("No existem dados para serem exibidos "); plot.setStartAngle(90); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(transparencia); plot.setInteriorGap(0.20); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:org.jfree.chart.demo.StackedBarChartDemo6.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 6", "Category", "Value", categorydataset, PlotOrientation.HORIZONTAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer(); stackedbarrenderer.setDrawBarOutline(false); long l = System.currentTimeMillis(); stackedbarrenderer.setBase(l);//from w w w . ja v a 2 s.c o m DateAxis dateaxis = new DateAxis("Date"); dateaxis.setLowerMargin(0.0D); categoryplot.setRangeAxis(dateaxis); return jfreechart; }
From source file:org.jfree.graphics2d.demo.SVGChartWithAnnotationsDemo1.java
private static JFreeChart createBarChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(10.0, "R1", "Q1"); dataset.addValue(7.0, "R1", "Q2"); dataset.addValue(8.0, "R1", "Q3"); dataset.addValue(4.0, "R1", "Q4"); dataset.addValue(10.6, "R2", "Q1"); dataset.addValue(6.1, "R2", "Q2"); dataset.addValue(8.5, "R2", "Q3"); dataset.addValue(4.3, "R2", "Q4"); JFreeChart chart = ChartFactory.createBarChart("Sales 2008", null, null, dataset); chart.removeLegend();/*from w w w .j ava 2s. c o m*/ chart.setBackgroundPainter(null); chart.getPlot().setBackgroundPainter(new ColorPainter(new Color(200, 200, 255, 60))); return chart; }
From source file:org.jfree.chart.demo.ItemLabelDemo3.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Item Label Demo 3", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.white); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setVisible(false);//from www . jav a 2 s . co m NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setUpperMargin(0.14999999999999999D); CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer(); StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator = new StandardCategoryItemLabelGenerator( "{1}", NumberFormat.getInstance()); categoryitemrenderer.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator); categoryitemrenderer.setBaseItemLabelFont(new Font("SansSerif", 0, 12)); categoryitemrenderer.setBaseItemLabelsVisible(true); categoryitemrenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, -1.5707963267948966D)); return jfreechart; }
From source file:org.jfree.chart.demo.LineChartDemo7.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Line Chart Demo 7", "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setSeriesShapesVisible(0, true); lineandshaperenderer.setSeriesShapesVisible(1, false); lineandshaperenderer.setSeriesShapesVisible(2, true); lineandshaperenderer.setSeriesLinesVisible(2, false); lineandshaperenderer.setSeriesShape(2, ShapeUtilities.createDiamond(4F)); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); return jfreechart; }
From source file:org.jfree.chart.demo.LineChartDemo8.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Line Chart Demo 8", "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis("Group", new String[] { "A", "B", "C", "D", "E", "F" }); categoryplot.setRangeAxis(symbolaxis); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setSeriesShapesVisible(0, true); lineandshaperenderer.setSeriesShapesVisible(1, false); lineandshaperenderer.setSeriesShapesVisible(2, true); lineandshaperenderer.setSeriesLinesVisible(2, false); lineandshaperenderer.setSeriesShape(2, ShapeUtilities.createDiamond(4F)); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); return jfreechart; }
From source file:org.jfree.chart.demo.StatisticalLineChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Statistical Line Chart Demo 1", "Type", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setUpperMargin(0.0D);//from w w w. j av a2 s .c o m categoryaxis.setLowerMargin(0.0D); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(true); StatisticalLineAndShapeRenderer statisticallineandshaperenderer = new StatisticalLineAndShapeRenderer(true, false); categoryplot.setRenderer(statisticallineandshaperenderer); return jfreechart; }
From source file:org.jfree.chart.demo.SubCategoryAxisDemo1.java
private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("SubCategoryAxis Demo 1", "Category", "Value", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); SubCategoryAxis subCategoryAxis = new SubCategoryAxis(null); subCategoryAxis.addSubCategory("S1"); subCategoryAxis.addSubCategory("S2"); subCategoryAxis.addSubCategory("S3"); plot.setDomainAxis(subCategoryAxis); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false);/* w w w.jav a2s .c o m*/ GradientPaint gradientpaint0 = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gradientpaint0); renderer.setSeriesPaint(1, gradientpaint1); renderer.setSeriesPaint(2, gradientpaint2); return chart; }
From source file:cn.edu.thss.iise.bpmdemo.charts.SWTPieChartDemo1.java
/** * Creates a chart.// w w w .j ava 2 s. c om * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart // title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:org.jfree.chart.demo.XYAreaChartDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setForegroundAlpha(0.65F);/*from w ww . ja v a 2 s . c om*/ xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setTickMarkPaint(Color.black); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setTickMarkPaint(Color.black); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Test", 5D, -500D, 2.3561944901923448D); xypointerannotation.setTipRadius(0.0D); xypointerannotation.setBaseRadius(35D); xypointerannotation.setFont(new Font("SansSerif", 0, 9)); xypointerannotation.setPaint(Color.blue); xypointerannotation.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); xyplot.addAnnotation(xypointerannotation); return jfreechart; }