Example usage for org.jfree.chart.plot XYPlot setAxisOffset

List of usage examples for org.jfree.chart.plot XYPlot setAxisOffset

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setAxisOffset.

Prototype

public void setAxisOffset(RectangleInsets offset) 

Source Link

Document

Sets the axis offsets (gap between the data area and the axes) and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:ch.unibe.iam.scg.archie.ui.charts.ConsultationNumberChart.java

/**
 * @see ch.unibe.iam.scg.archie.ui.charts.AbstractChartComposite#
 * initializeChart()/* ww  w .  j ava 2s .  com*/
 */
@Override
protected JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(ConsultationNumberChart.CHART_TITLE, // title
            "", // x-axis label
            "Count", // y-axis label
            (XYDataset) this.creator.getDataset(), // data
            false, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(new Color(this.parent.getBackground().getRed(),
            this.parent.getBackground().getGreen(), this.parent.getBackground().getBlue()));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;
}

From source file:Utils.GeneradorDeGraficas.java

public JFreeChart graficarCostos(DeterministaGeneral general, String unidad) {
    XYDataset dataset;//from w w w .  ja v a  2s.  c om

    dataset = createDatasetCosto(general, unidad);

    JFreeChart chart = ChartFactory.createXYLineChart("Anlisis de Costo de Inventario por " + unidad,
            "Cantidad de pedido", "Costo", dataset, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(4, black, true);
    renderer.setSeriesPaint(3, black, true);

    /* renderer.setShapesFilled(true);
     renderer.setShapesVisible(true);*/

    XYPlot plot2 = chart.getXYPlot();
    NumberAxis rangeAxis = (NumberAxis) plot2.getRangeAxis();
    rangeAxis.setAutoRange(false);

    rangeAxis.setUpperBound(general.calcularCostoGrafica(general.calcularCantidadOptimaOrdenar()) * 2);

    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.SuperNormalDistributionChart.java

/**
 * Creates a chart.//from  w ww  . ja  v  a2  s  . c  o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo2.java

/**
 * Creates a chart.//from   ww w  .j av a  2  s  .com
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    setXSummary(dataset);
    return chart;

}

From source file:ch.unibe.iam.scg.archie.ui.charts.ConsultationMoneyChart.java

/**
 * @see ch.unibe.iam.scg.archie.ui.charts.AbstractChartComposite#
 * initializeChart()//from   w  ww . j  av  a  2  s  . c  o m
 */
@Override
protected JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(ConsultationMoneyChart.CHART_TITLE, // title
            "", // x-axis label
            "Amount", // y-axis label
            (XYDataset) this.creator.getDataset(), // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    // Set chart background color to it's parents background
    chart.setBackgroundPaint(new Color(this.parent.getBackground().getRed(),
            this.parent.getBackground().getGreen(), this.parent.getBackground().getBlue()));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;
}

From source file:ws.moor.bt.gui.charts.RawDownloadRate.java

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Download Rate", "Time", "KB/s", dataset, false,
            false, false);/*from  ww w .  ja  va  2s  .c  o m*/
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    return chart;
}

From source file:ws.moor.bt.gui.charts.RemotePeerCompletion.java

private JFreeChart createChart(HistogramDataset dataset) {

    JFreeChart chart = ChartFactory.createHistogram("Remote Peer Completion", "Completion %", "Peers", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setRangeCrosshairVisible(true);

    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setRange(0.0, 100.0);

    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo6.java

/**
 * Creates a chart.//from  w  w w . jav a  2s.  c  o m
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    // renderer.setSeriesLinesVisible(0, false);
    //   renderer.setSeriesShapesVisible(1, false);
    renderer.setBaseLinesVisible(false);

    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:ws.moor.bt.gui.charts.ConnectionTypes.java

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Connection Types", "Time", "Connections", dataset,
            true, false, false);/*from w w w  .  j a  v a2 s. co  m*/
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    return chart;
}

From source file:com.bt.aloha.batchtest.Chart.java

private JFreeChart createChart(XYDataset xydataset, String title, String xLabel, String yLabel) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart(title, xLabel, yLabel, 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);
    if (xydataset instanceof IntervalXYDataset) {
        DeviationRenderer deviationrenderer = new DeviationRenderer(true, true);
        deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
        deviationrenderer.setSeriesFillPaint(0, new Color(255, 200, 200));
        xyplot.setRenderer(deviationrenderer);
    }//from w w  w . j ava 2  s  .c o  m
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setAutoRange(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return jfreechart;
}