List of usage examples for org.jfree.chart.plot XYPlot setInsets
public void setInsets(RectangleInsets insets)
From source file:org.jfree.chart.demo.SparklineDemo1.java
public static void main(String args[]) { XYSeries xyseries = new XYSeries("Series 1"); xyseries.add(1.0D, 1.0D);// ww w.j a v a 2 s.c om xyseries.add(2D, 3D); xyseries.add(3D, 2D); xyseries.add(4D, 4D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); JFreeChart jfreechart = ChartFactory.createXYLineChart(null, "X", "Y", xyseriescollection, PlotOrientation.VERTICAL, false, false, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setInsets(RectangleInsets.ZERO_INSETS); xyplot.setDomainGridlinesVisible(false); xyplot.setRangeGridlinesVisible(false); xyplot.setOutlinePaint(null); xyplot.getDomainAxis().setVisible(false); xyplot.getRangeAxis().setVisible(false); try { ChartUtilities.saveChartAsPNG(new File("Sparky.png"), jfreechart, 100, 20); } catch (IOException ioexception) { ioexception.printStackTrace(); } }
From source file:org.jfree.chart.demo.DeviationRendererDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Projected Values - Test", "Date", "Index Projection", xydataset, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); //// www.jav a2 s.c om 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); // NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:de.aidger.view.utils.Charts.java
/** * Creates a xy area chart./*from w w w .j a v a2s. c o m*/ * * @param title * the diagram title * @param dataset * the dataset. * @param width * the width of the chart as image * @param height * the height of the chart as image * @return the xy area chart as image */ public static ImageIcon createXYAreaChart(String title, XYDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createXYAreaChart(title, "", "", dataset, PlotOrientation.VERTICAL, false, false, false); Font titleFont = UIManager.getFont("TitledBorder.font"); chart.setBackgroundPaint(null); chart.getTitle().setFont(new Font(titleFont.getName(), titleFont.getStyle(), 14)); chart.getTitle().setPaint(UIManager.getColor("TitledBorder.titleColor")); chart.setBorderPaint(null); XYPlot plot = chart.getXYPlot(); plot.setInsets(new RectangleInsets(10, 1, 5, 1)); plot.setBackgroundPaint(null); plot.setOutlineVisible(false); plot.setNoDataMessage(_("No data to display.")); ValueAxis domainAxis = new DateAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setTickLabelFont(UIManager.getFont("RootPane.font")); ValueAxis rangeAxis = new NumberAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setDomainAxis(domainAxis); plot.setRangeAxis(rangeAxis); plot.setForegroundAlpha(0.5f); return new ImageIcon(chart.createBufferedImage(width, height)); }
From source file:plugins.tutorial.chart.ChartTutorial2.java
/** * Creates a sample chart./*from ww w. jav a2s . co m*/ * * @param dataset * the dataset. * @return The chart. */ private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Projected Values - Test", "Date", "Index Projection", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); DeviationRenderer deviationrenderer = new DeviationRenderer(true, false); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesFillPaint(0, new Color(255, 200, 200)); deviationrenderer.setSeriesFillPaint(1, new Color(200, 200, 255)); xyplot.setRenderer(deviationrenderer); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.fhaes.fhsamplesize.view.SSIZCurveChart.java
/** * Create the chart.//from w w w . j a va 2s.c o m * * @param eventsPerCenturyDataset * @return */ private static JFreeChart createChart(final XYDataset eventsPerCenturyDataset, Integer xcross, Integer ycross) { // JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(null, "Number of series resampled", "Number of events", // eventsPerCenturyDataset, true, true, false); JFreeChart jfreechart = ChartFactory.createScatterPlot(null, "Number of series resampled", "Number of events per century", eventsPerCenturyDataset); jfreechart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); // xyplot.setDomainGridlinePaint(Color.white); // xyplot.setRangeGridlinePaint(Color.white); DeviationRenderer deviationrenderer = new DeviationRenderer(true, false); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesFillPaint(0, new Color(255, 200, 200)); deviationrenderer.setSeriesFillPaint(1, new Color(200, 200, 255)); xyplot.setRenderer(deviationrenderer); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); jfreechart.removeLegend(); if (xcross != null && ycross != null) { XYPlot xyp = jfreechart.getXYPlot(); xyp.setRangeCrosshairVisible(true); xyp.setRangeCrosshairValue(ycross, true); xyp.setRangeCrosshairLockedOnData(true); xyp.setDomainCrosshairVisible(true); xyp.setDomainCrosshairValue(xcross, true); xyp.setDomainCrosshairLockedOnData(true); } // Initialize the chart variable for later use chart = jfreechart; return jfreechart; }
From source file:com.projity.pm.graphic.chart.ChartHelper.java
public static void removeAxisAndInsets(XYPlot plot) { plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); plot.setDomainGridlinesVisible(false); plot.setInsets(new RectangleInsets(0, 0, BOTTOM_INSET, 0)); }
From source file:org.jfree.chart.demo.ThumbnailDemo1.java
private static JFreeChart createChart4(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Projected Values - Test", "Date", "Index Projection", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); DeviationRenderer deviationrenderer = new DeviationRenderer(true, false); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesFillPaint(0, new Color(255, 200, 200)); deviationrenderer.setSeriesFillPaint(1, new Color(200, 200, 255)); xyplot.setRenderer(deviationrenderer); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:ec.util.chart.swing.Charts.java
/** * A sparkline is a type of information graphic characterized by its small * size and high data density. Sparklines present trends and variations * associated with some measurement, such as average temperature or stock * market activity, in a simple and condensed way. Several sparklines are * often used together as elements of a small multiple.<br> * * {@link http://en.wikipedia.org/wiki/Sparkline} * * @param dataset//from w ww. ja v a2 s.c o m * @return * @author Philippe Charles */ @Nonnull public static JFreeChart createSparkLineChart(@Nonnull XYDataset dataset) { JFreeChart result = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, false, false); result.setBorderVisible(false); result.setBackgroundPaint(null); result.setAntiAlias(true); XYPlot plot = result.getXYPlot(); plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setOutlineVisible(false); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); plot.setBackgroundPaint(null); ((XYLineAndShapeRenderer) plot.getRenderer()).setAutoPopulateSeriesPaint(false); return result; }
From source file:org.sonar.server.charts.deprecated.SparkLinesChart.java
private void configurePlot() { XYPlot plot = (XYPlot) jfreechart.getPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setDataset(dataset);/*from www . j av a2s . c o m*/ plot.setDomainAxis(x); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setRangeAxis(y); plot.setRenderer(renderer); plot.setBackgroundAlpha(0.0f); }
From source file:org.webcat.grader.graphs.BoxAndWhiskerChart.java
@Override protected JFreeChart generateChart(WCChartTheme chartTheme) { setChartHeight(36);/*from ww w. j a va 2s .c om*/ JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, yAxisLabel(), boxAndWhiskerXYDataset(), false); chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); chart.setPadding(new RectangleInsets(0, 6, 0, 6)); XYPlot plot = chart.getXYPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setOutlineVisible(false); plot.setBackgroundPaint(new Color(0, 0, 0, 0)); XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer(); renderer.setAutoPopulateSeriesOutlinePaint(true); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(false); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(-0.5, assignmentOffering.assignment().submissionProfile().availablePoints() + 0.5); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); Font oldFont = rangeAxis.getTickLabelFont(); rangeAxis.setTickLabelFont(oldFont.deriveFont(oldFont.getSize2D() * 0.8f)); return chart; }