List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:org.jfree.chart.demo.StackedXYBarChartDemo3.java
private static JFreeChart createChart(TableXYDataset tablexydataset) { DateAxis dateaxis = new DateAxis("Year"); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);/*from w ww . j av a2 s. c o m*/ dateaxis.setUpperMargin(0.01D); NumberAxis numberaxis = new NumberAxis("Tonnes"); numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%")); StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.29999999999999999D); stackedxybarrenderer.setRenderAsPercentages(true); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, new Color(64, 0, 0), 0.0F, 0.0F, Color.red); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, new Color(0, 64, 0), 0.0F, 0.0F, Color.green); stackedxybarrenderer.setSeriesPaint(0, gradientpaint); stackedxybarrenderer.setSeriesPaint(1, gradientpaint1); stackedxybarrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); stackedxybarrenderer.setDrawBarOutline(false); stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2} tonnes", new SimpleDateFormat("yyyy"), new DecimalFormat("#,##0"))); XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); JFreeChart jfreechart = new JFreeChart("Waste Management", xyplot); jfreechart.setBackgroundPaint(Color.white); jfreechart.addSubtitle(new TextTitle("St Albans City and District Council")); return jfreechart; }
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);/* www. ja v a 2 s. c o m*/ 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; }
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); }/*from w ww.j a va 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: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); }/*w w w.j a v a 2 s . c om*/ 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.DeviationRendererDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createXYLineChart("DeviationRenderer - Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); //A specialised subclass of the {@link XYLineAndShapeRenderer} that requires // an {@link IntervalXYDataset} and represents the y-interval by shading an // area behind the y-values on the chart. DeviationRenderer renderer = new DeviationRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); renderer.setSeriesFillPaint(0, new Color(255, 200, 200)); renderer.setSeriesFillPaint(1, new Color(200, 200, 255)); plot.setRenderer(renderer);/*from w w w.ja v a 2 s.c o m*/ // NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
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)); }//from w ww . ja va2 s .c om return jfreechart; }
From source file:org.jfree.chart.demo.CrosshairDemo4.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Crosshair Demo 4", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.jfree.chart.demo.XYLineAndShapeRendererDemo2.java
private static JFreeChart createChart() { XYDataset xydataset = createDataset(1, 1.0D); JFreeChart jfreechart = ChartFactory.createXYLineChart("XYLineAndShapeRenderer Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); TextTitle texttitle = new TextTitle( "This chart shows various combinations of the useFillPaint and useOutlinePaint flags."); texttitle.setFont(new Font("Dialog", 0, 10)); jfreechart.addSubtitle(texttitle);/*from w w w .j av a 2 s. c om*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); java.awt.geom.Ellipse2D.Double double1 = new java.awt.geom.Ellipse2D.Double(-4D, -4D, 8D, 8D); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setSeriesShape(0, double1); xylineandshaperenderer.setSeriesPaint(0, Color.red); xylineandshaperenderer.setSeriesFillPaint(0, Color.yellow); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.gray); XYDataset xydataset1 = createDataset(2, 2D); XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(); xyplot.setDataset(1, xydataset1); xyplot.setRenderer(1, xylineandshaperenderer1); xylineandshaperenderer1.setSeriesShape(0, double1); xylineandshaperenderer1.setSeriesPaint(0, Color.red); xylineandshaperenderer1.setSeriesFillPaint(0, Color.yellow); xylineandshaperenderer1.setSeriesOutlinePaint(0, Color.gray); xylineandshaperenderer1.setUseFillPaint(true); XYDataset xydataset2 = createDataset(3, 3D); XYLineAndShapeRenderer xylineandshaperenderer2 = new XYLineAndShapeRenderer(); xyplot.setDataset(2, xydataset2); xyplot.setRenderer(2, xylineandshaperenderer2); xylineandshaperenderer2.setSeriesShape(0, double1); xylineandshaperenderer2.setSeriesPaint(0, Color.red); xylineandshaperenderer2.setSeriesFillPaint(0, Color.yellow); xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.gray); xylineandshaperenderer2.setUseOutlinePaint(true); XYDataset xydataset3 = createDataset(4, 4D); XYLineAndShapeRenderer xylineandshaperenderer3 = new XYLineAndShapeRenderer(); xyplot.setDataset(3, xydataset3); xyplot.setRenderer(3, xylineandshaperenderer3); xylineandshaperenderer3.setSeriesShape(0, double1); xylineandshaperenderer3.setSeriesPaint(0, Color.red); xylineandshaperenderer3.setSeriesFillPaint(0, Color.yellow); xylineandshaperenderer3.setSeriesOutlinePaint(0, Color.gray); xylineandshaperenderer3.setUseOutlinePaint(true); xylineandshaperenderer3.setUseFillPaint(true); XYDataset xydataset4 = createDataset(5, 5D); XYLineAndShapeRenderer xylineandshaperenderer4 = new XYLineAndShapeRenderer(); xyplot.setDataset(4, xydataset4); xyplot.setRenderer(4, xylineandshaperenderer4); xylineandshaperenderer4.setSeriesShape(0, double1); xylineandshaperenderer4.setSeriesPaint(0, Color.red); xylineandshaperenderer4.setSeriesFillPaint(0, Color.yellow); xylineandshaperenderer4.setSeriesOutlinePaint(0, Color.gray); xylineandshaperenderer4.setUseOutlinePaint(true); xylineandshaperenderer4.setUseFillPaint(true); xylineandshaperenderer4.setDrawOutlines(false); return jfreechart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo2.java
private static JFreeChart createChart(XYZDataset xyzdataset) { DateAxis dateaxis = new DateAxis("Date"); dateaxis.setLowerMargin(0.0D);//w w w . ja va2 s . c o m dateaxis.setUpperMargin(0.0D); dateaxis.setInverted(true); NumberAxis numberaxis = new NumberAxis("Hour"); numberaxis.setUpperMargin(0.0D); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); xyblockrenderer.setBlockWidth(86400000D); xyblockrenderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT); LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 4.5D, Color.white); lookuppaintscale.add(0.5D, Color.red); lookuppaintscale.add(1.5D, Color.green); lookuppaintscale.add(2.5D, Color.blue); lookuppaintscale.add(3.5D, Color.yellow); xyblockrenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, dateaxis, numberaxis, xyblockrenderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo2", xyplot); jfreechart.removeLegend(); jfreechart.setBackgroundPaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "Unavailable", "Free", "Group 1", "Group 2" }); symbolaxis.setRange(0.5D, 4.5D); symbolaxis.setPlot(new PiePlot()); symbolaxis.setGridBandsVisible(false); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis); paintscalelegend.setMargin(new RectangleInsets(3D, 10D, 3D, 10D)); paintscalelegend.setPosition(RectangleEdge.BOTTOM); paintscalelegend.setAxisOffset(5D); jfreechart.addSubtitle(paintscalelegend); return jfreechart; }
From source file:org.jfree.chart.demo.MultipleAxisDemo4.java
private static JFreeChart createChart() { XYDataset xydataset = createDataset("March 2007", 100D, new Day(1, 3, 2007), 31); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 4", "Date", "Value", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setOrientation(PlotOrientation.VERTICAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy")); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.red); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setTickLabelPaint(Color.red); DateAxis dateaxis1 = new DateAxis("Date"); dateaxis1.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy")); xyplot.setDomainAxis(1, dateaxis1);// w w w . j a v a 2 s .c o m xyplot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT); NumberAxis numberaxis1 = new NumberAxis("Value"); numberaxis1.setAutoRangeIncludesZero(false); numberaxis1.setTickLabelPaint(Color.blue); xyplot.setRangeAxis(1, numberaxis1); xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); XYDataset xydataset1 = createDataset("July 2007", 1000D, new Day(1, 7, 2007), 31); xyplot.setDataset(1, xydataset1); xyplot.mapDatasetToDomainAxis(1, 1); xyplot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.blue); xyplot.setRenderer(1, xylineandshaperenderer); return jfreechart; }