List of usage examples for org.jfree.chart JFreeChart getPlot
public Plot getPlot()
From source file:org.jfree.chart.demo.StackedBarChart3DDemo5.java
private static JFreeChart createChart(int i, CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("Chart " + (i + 1), "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, false, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.getDomainAxis().setMaximumCategoryLabelLines(2); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = categoryplot.getRangeAxis(); valueaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:com.wsn.PieChartDemo.java
/** * Creates a chart.//w w w . j a va2s .com * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo", // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); 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.MouseOverDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Mouseover Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); MyBarRenderer mybarrenderer = new MyBarRenderer(); mybarrenderer.setDrawBarOutline(true); categoryplot.setRenderer(mybarrenderer); ChartUtilities.applyCurrentTheme(jfreechart); GradientPaint gradientpaint = 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)); mybarrenderer.setSeriesPaint(0, gradientpaint); mybarrenderer.setSeriesPaint(1, gradientpaint1); mybarrenderer.setSeriesPaint(2, gradientpaint2); return jfreechart; }
From source file:userInterface.ManufactureRole.DecisionChartJPanel.java
private static JFreeChart createChart1(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Vaccine Sales", "Vaccine", "quantity", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.blue); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = 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)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:eu.delving.sip.base.ReportChartHelper.java
public static JComponent createLinkChart(DataSet dataSet, String prefix, Map<RecDef.Check, LinkFile.LinkStats> linkStatsMap) { JPanel p = new JPanel(new GridLayout(0, 1)); for (Map.Entry<RecDef.Check, LinkFile.LinkStats> entry : linkStatsMap.entrySet()) { JPanel pp = new JPanel(new GridLayout(1, 0)); pp.setBorder(BorderFactory.createTitledBorder(entry.getKey().toString())); for (Map.Entry<String, PieDataset> datasetEntry : entry.getValue().createPies().entrySet()) { JFreeChart chart = ChartFactory.createRingChart(datasetEntry.getKey(), datasetEntry.getValue(), true, false, Locale.getDefault()); RingPlot plot = (RingPlot) chart.getPlot(); plot.setLabelGenerator(null); plot.setNoDataMessage("No data available"); plot.setSectionDepth(0.34999999999999998D); plot.setCircular(true);/*from ww w . j ava2 s . c o m*/ plot.setLabelGap(0.02D); pp.add(new ChartPanel(chart)); } p.add(pp); } return p; }
From source file:org.jfree.chart.demo.PerformanceTest1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Performance Test 1", "Time", "Milliseconds", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer standardxyitemrenderer = (StandardXYItemRenderer) xyitemrenderer; standardxyitemrenderer.setSeriesStroke(0, new BasicStroke(1.1F)); }/*w w w.j a v a 2 s. c om*/ return jfreechart; }
From source file:org.jfree.chart.demo.YieldCurveDemo.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield", xydataset, false, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15); xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime())); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }//from ww w . j a va2s . c om DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); jfreechart.addSubtitle(new TextTitle("November 2005")); TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm"); texttitle.setFont(new Font("Dialog", 0, 9)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle); return jfreechart; }
From source file:org.jfree.chart.demo.PeriodAxisDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setBaseItemLabelsVisible(true); }//from w w w. j ava 2 s .co m PeriodAxis periodaxis = new PeriodAxis("Date"); periodaxis.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Month.class); periodaxis.setMajorTickTimePeriodClass(org.jfree.data.time.Month.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis); return jfreechart; }
From source file:org.jfree.chart.demo.XYTitleAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, false, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); LegendTitle legendtitle = new LegendTitle(xyplot); legendtitle.setItemFont(new Font("Dialog", 0, 9)); legendtitle.setBackgroundPaint(new Color(200, 200, 255, 100)); legendtitle.setFrame(new BlockBorder(Color.white)); legendtitle.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.02D, legendtitle, RectangleAnchor.BOTTOM_RIGHT); xytitleannotation.setMaxWidth(0.47999999999999998D); xyplot.addAnnotation(xytitleannotation); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }//w w w.j a v a 2 s.c om DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ValueAxis valueaxis = xyplot.getRangeAxis(); valueaxis.setLowerMargin(0.34999999999999998D); return jfreechart; }
From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerAndPredictionDifference.java
private static JFreeChart createChart() { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(NAME, "Power (Watts)", "Power (Watts)", data, true, true, false);//from w w w.j a v a 2 s. com jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.yellow, false); xydifferencerenderer.setRoundXCoordinates(true); xyplot.setDomainCrosshairLockedOnData(true); xyplot.setRangeCrosshairLockedOnData(true); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setRenderer(xydifferencerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DateAxis dateaxis = new DateAxis("Samples"); dateaxis.setTickLabelsVisible(false); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); xyplot.setForegroundAlpha(0.5F); return jfreechart; }