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:mekhq.gui.FinancesTab.java

private JFreeChart createAmountChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", // title
            resourceMap.getString("graphDate.text"), // x-axis label
            resourceMap.getString("graphCBills.text"), // y-axis label
            dataset);/*  ww  w  . j  a va2s  .  com*/

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    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);

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

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

    chart.removeLegend();

    return chart;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.SimpleBlockChart.java

/**
 * Creates a chart for the specified dataset.
 * //from   w w w.  j av  a  2  s.  c o  m
 * @param dataset  the dataset.
 * 
 * @return A chart instance.
 */
public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    XYZDataset dataset = (XYZDataset) datasets.getDatasets().get("1");

    JFreeChart chart = null;

    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    if (xLowerBound != null && xUpperBound != null) {
        xAxis.setLowerBound(xLowerBound);
        xAxis.setUpperBound(xUpperBound);
    } else {
        xAxis.setAutoRange(true);
    }
    xAxis.setAxisLinePaint(Color.white);
    xAxis.setTickMarkPaint(Color.white);

    if (addLabelsStyle != null && addLabelsStyle.getFont() != null) {
        xAxis.setLabelFont(addLabelsStyle.getFont());
        xAxis.setLabelPaint(addLabelsStyle.getColor());
    }

    NumberAxis yAxis = new NumberAxis(yLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    if (yLowerBound != null && yUpperBound != null) {
        yAxis.setLowerBound(yLowerBound);
        yAxis.setUpperBound(yUpperBound);
    } else
        yAxis.setAutoRange(true);

    yAxis.setAxisLinePaint(Color.white);
    yAxis.setTickMarkPaint(Color.white);

    if (addLabelsStyle != null && addLabelsStyle.getFont() != null) {
        yAxis.setLabelFont(addLabelsStyle.getFont());
        yAxis.setLabelPaint(addLabelsStyle.getColor());
    }

    XYBlockRenderer renderer = new XYBlockRenderer();

    PaintScale paintScale = null;

    if (grayPaintScale) {
        paintScale = new GrayPaintScale(minScaleValue, maxScaleValue);
    } else {
        if (scaleLowerBound != null && scaleUpperBound != null) {
            paintScale = new LookupPaintScale(scaleLowerBound, scaleUpperBound, Color.gray);
        } else {
            paintScale = new LookupPaintScale(minScaleValue, maxScaleValue, Color.gray);
        }
        for (int i = 0; i < zRangeArray.length; i++) {
            ZRange zRange = zRangeArray[i];
            ((LookupPaintScale) paintScale).add(zRange.getValue().doubleValue(), zRange.getColor());

        }
    }

    renderer.setPaintScale(paintScale);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setForegroundAlpha(0.66f);

    chart = new JFreeChart(plot);
    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    chart.removeLegend();

    NumberAxis scaleAxis = new NumberAxis(zLabel);
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7));
    if (scaleLowerBound != null && scaleUpperBound != null) {
        scaleAxis.setLowerBound(scaleLowerBound);
        scaleAxis.setUpperBound(scaleUpperBound);
    } else
        scaleAxis.setAutoRange(true);

    if (addLabelsStyle != null && addLabelsStyle.getFont() != null) {
        scaleAxis.setLabelFont(addLabelsStyle.getFont());
        scaleAxis.setLabelPaint(addLabelsStyle.getColor());
    }

    if (blockHeight != null && blockWidth != null) {
        renderer.setBlockWidth(blockWidth.doubleValue());
        renderer.setBlockHeight(blockHeight.doubleValue());
    }

    PaintScaleLegend legend = new PaintScaleLegend(paintScale, scaleAxis);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5.0);
    legend.setMargin(new RectangleInsets(5, 5, 5, 5));
    legend.setFrame(new BlockBorder(Color.black));
    legend.setPadding(new RectangleInsets(10, 10, 10, 10));
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.RIGHT);
    legend.setBackgroundPaint(color);

    chart.addSubtitle(legend);

    //      chart.setBackgroundPaint(new Color(180, 180, 250));   
    chart.setBackgroundPaint(color);

    logger.debug("OUT");
    return chart;
}

From source file:com.rapidminer.gui.plotter.charts.SeriesChartPlotter.java

private JFreeChart createChart(XYDataset dataset, boolean createLegend) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            null, // x axis label
            null, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, createLegend, // include legend
            true, // tooltips
            false // urls
    );/*from   w ww  .ja  v a 2 s .c  o  m*/

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customization...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    DeviationRenderer renderer = new DeviationRenderer(true, false);

    // colors
    if (dataset.getSeriesCount() == 1) {
        renderer.setSeriesStroke(0, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
        renderer.setSeriesPaint(0, getColorProvider().getPointColor(1.0d));
    } else { // special case needed for avoiding devision by zero
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            renderer.setSeriesStroke(i, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
            renderer.setSeriesPaint(i,
                    getColorProvider().getPointColor(1.0d - i / (double) (dataset.getSeriesCount() - 1)));
        }
    }
    // background for bounds
    if (plotBounds) {
        float[] dashArray = new float[] { 7, 14 };
        renderer.setSeriesStroke(boundsSeriesIndex,
                new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dashArray, 0));
        renderer.setSeriesPaint(boundsSeriesIndex, Color.GRAY.brighter());
        renderer.setSeriesFillPaint(boundsSeriesIndex, Color.GRAY);
    }
    // alpha
    renderer.setAlpha(0.25f);

    plot.setRenderer(renderer);

    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    if (axis[INDEX] < 0) {
        xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
        xAxis.setLabel(SERIESINDEX_LABEL);
        Range range = getRangeForName(SERIESINDEX_LABEL);
        if (range == null) {
            xAxis.setAutoRange(true);
            xAxis.setAutoRangeStickyZero(false);
            xAxis.setAutoRangeIncludesZero(false);
        } else {
            xAxis.setRange(range, true, false);
        }
    } else {
        xAxis.setLabel(dataTable.getColumnName(axis[INDEX]));
        Range range = getRangeForDimension(axis[INDEX]);
        if (range == null) {
            xAxis.setAutoRange(true);
            xAxis.setAutoRangeStickyZero(false);
            xAxis.setAutoRangeIncludesZero(false);
        } else {
            xAxis.setRange(range, true, false);
        }
    }

    xAxis.setLabelFont(LABEL_FONT_BOLD);
    xAxis.setTickLabelFont(LABEL_FONT);
    xAxis.setVerticalTickLabels(isLabelRotating());

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLabel(VALUEAXIS_LABEL);
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));
    setYAxisRange(yAxis);

    yAxis.setLabelFont(LABEL_FONT_BOLD);
    yAxis.setTickLabelFont(LABEL_FONT);

    return chart;
}

From source file:com.freedomotic.jfrontend.extras.GraphPanel.java

private void createChart(UsageDataFrame points, String title) {
    series = new TimeSeries(title);

    for (UsageData d : points.getData()) {
        Date resultdate = d.getDateTime();
        Millisecond ms_read = new Millisecond(resultdate);
        int poweredValue = -1;
        if (d.getObjBehavior().equalsIgnoreCase("powered")) {
            poweredValue = d.getObjValue().equalsIgnoreCase("true") ? 1 : 0;
        } else if (d.getObjBehavior().equalsIgnoreCase("brigthness")) {
            try {
                poweredValue = Integer.parseInt(d.getObjValue());
            } catch (NumberFormatException ex) {
                poweredValue = -1;//w w w .ja v  a 2 s .  c  om
            }
        }
        series.addOrUpdate(ms_read, poweredValue);
    }

    XYDataset xyDataset = new TimeSeriesCollection(series);

    chart = ChartFactory.createTimeSeriesChart("Chart", "TIME", "VALUE", xyDataset, true, // legend
            true, // tooltips
            false // urls
    );
    chart.setAntiAlias(true);
    // Set plot styles
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    // Set series line styles
    plot.setRenderer(new XYStepRenderer());

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setShapesVisible(true);
        renderer.setShapesFilled(true);
    }

    // Set date axis style
    DateAxis axis = (DateAxis) plot.getDomainAxis();

    String formatString = "MM-dd HH";
    DateTickUnitType dtut = DateTickUnitType.HOUR;

    if (jComboGranularity.getSelectedItem().equals("Year")) {
        formatString = "yyyy";
        dtut = DateTickUnitType.YEAR;
    } else if (jComboGranularity.getSelectedItem().equals("Month")) {
        axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM"));
        dtut = DateTickUnitType.MONTH;
    } else if (jComboGranularity.getSelectedItem().equals("Day")) {
        axis.setDateFormatOverride(new SimpleDateFormat("MM-dd"));
        dtut = DateTickUnitType.DAY;
    } else if (jComboGranularity.getSelectedItem().equals("Minute")) {
        formatString = "MM-dd HH:mm";
        dtut = DateTickUnitType.MINUTE;
    } else if (jComboGranularity.getSelectedItem().equals("Second")) {
        formatString = "HH:mm:SS";
        dtut = DateTickUnitType.SECOND;
    }

    DateFormat formatter = new SimpleDateFormat(formatString);
    DateTickUnit unit = new DateTickUnit(dtut, 1, formatter);
    axis.setTickUnit(unit);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, 500));
    graphPanel.removeAll();
    graphPanel.add(chartPanel);

}

From source file:org.eumetsat.metop.visat.SounderInfoView.java

protected void configureSpectrumPlot(XYPlot plot) {
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);
    plot.setNoDataMessage(NO_IFOV_SELECTED);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.blockcharts.TimeBlockChart.java

@Override
public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    super.createChart(datasets);
    DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1");

    DateAxis xAxis = new DateAxis(yLabel);
    xAxis.setLowerMargin(0.0);/*from   ww w  .j  ava 2  s .co m*/
    xAxis.setUpperMargin(0.0);
    xAxis.setInverted(false);
    xAxis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy"));
    if (dateAutoRange) {
        xAxis.setAutoRange(true);
    } else {
        DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 1, formatter);
        xAxis.setTickUnit(unit);
    }

    if (dateMin != null && dateMax != null) {
        xAxis.setRange(dateMin, addDay(dateMax));
    } else {
        xAxis.setRange(minDateFound, addDay(maxDateFound));
    }

    //      Calendar c=new GregorianCalendar();
    //      c.set(9 + 2000, Calendar.JANUARY, 1);
    //      java.util.Date minima=c.getTime();
    //      Calendar c1=new GregorianCalendar();
    //      c1.set(9 + 2000, Calendar.FEBRUARY, 1);
    //      java.util.Date massima=c1.getTime();

    NumberAxis yAxis = new NumberAxis(xLabel);
    yAxis.setUpperMargin(0.0);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setRange(hourMin, hourMax);

    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBlockWidth(BLOCK_HEIGHT);
    // one block for each minute!
    renderer.setBlockHeight(0.017);
    //renderer.setBlockWidth(1);
    renderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT);

    //      MyXYItemLabelGenerator my=new MyXYItemLabelGenerator();
    //      renderer.setItemLabelsVisible(null);
    //      renderer.setSeriesItemLabelGenerator(0, my);
    //      renderer.setSeriesItemLabelsVisible(0, true);

    //      XYTextAnnotation annotation1 = new XYTextAnnotation(
    //      "P_",1.2309372E12, 14.3);
    //      XYTextAnnotation annotation2 = new XYTextAnnotation(
    //      "P_",1.2308508E12, 16.3);

    for (Iterator iterator = annotations.keySet().iterator(); iterator.hasNext();) {
        String annotationCode = (String) iterator.next();
        AnnotationBlock annotationBlock = annotations.get(annotationCode);
        XYTextAnnotation xyAnnotation = new XYTextAnnotation(annotationBlock.getAnnotation(),
                annotationBlock.getXPosition() + ANNOTATION_HEIGHT, annotationBlock.getYPosition());
        if (styleAnnotation != null) {
            xyAnnotation.setFont(new Font(styleAnnotation.getFontName(), Font.BOLD, styleAnnotation.getSize()));
            xyAnnotation.setPaint(styleAnnotation.getColor());
        } else {
            xyAnnotation.setFont(new Font("Nome", Font.BOLD, 8));
            xyAnnotation.setPaint(Color.BLACK);
        }

        xyAnnotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
        renderer.addAnnotation(xyAnnotation);
    }

    logger.debug("Annotation set");

    LookupPaintScale paintScale = new LookupPaintScale(0.5, ranges.size() + 0.5, color);
    String[] labels = new String[ranges.size() + 1];
    labels[0] = "";

    // ******************** SCALE ****************************
    for (Iterator iterator = ranges.iterator(); iterator.hasNext();) {
        RangeBlocks range = (RangeBlocks) iterator.next();
        Integer index = patternRangeIndex.get(range.getPattern());
        Color color = range.getColor();
        if (color != null) {
            //Paint colorTransparent=new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);         
            Paint colorTransparent = null;
            if (addTransparency == true) {
                colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);
            } else {
                colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue());
            }
            paintScale.add(index + 0.5, colorTransparent);
        }
        //String insertLabel="            "+range.getLabel();
        String insertLabel = range.getLabel();
        labels[index + 1] = insertLabel;
    }
    renderer.setPaintScale(paintScale);

    SymbolAxis scaleAxis = new SymbolAxis(null, labels);
    scaleAxis.setRange(0.5, ranges.size() + 0.5);
    scaleAxis.setPlot(new PiePlot());
    scaleAxis.setGridBandsVisible(false);

    org.jfree.chart.title.PaintScaleLegend psl = new PaintScaleLegend(paintScale, scaleAxis);
    psl.setMargin(new RectangleInsets(3, 10, 3, 10));
    psl.setPosition(RectangleEdge.BOTTOM);
    psl.setAxisOffset(5.0);
    // ******************** END SCALE ****************************

    logger.debug("Scale Painted");

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));

    logger.debug("Plot set");

    JFreeChart chart = new JFreeChart(name, plot);
    if (styleTitle != null) {
        TextTitle title = setStyleTitle(name, styleTitle);
        chart.setTitle(title);
    }
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    chart.addSubtitle(psl);

    logger.debug("OUT");

    return chart;

}

From source file:org.eumetsat.metop.visat.IasiInfoView.java

private void configureSpectrumPlot(XYPlot plot) {
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);
    plot.setNoDataMessage(NO_IFOV_SELECTED);
}

From source file:net.nosleep.superanalyzer.analysis.views.YearView.java

private void createChart() {

    NumberAxis xAxis = new NumberAxis(Misc.getString("RELEASE_YEAR"));
    xAxis.setAutoRangeIncludesZero(false);

    NumberAxis yAxis = new NumberAxis(Misc.getString("SONG_COUNT"));
    yAxis.setAutoRangeIncludesZero(true);

    xAxis.setNumberFormatOverride(new DecimalFormat("0"));

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot(_dataset, xAxis, yAxis, renderer);

    // create and return the chart panel...
    _chart = new JFreeChart(Misc.getString("RELEASE_YEAR"), JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));

    LegendTitle legend = _chart.getLegend();
    legend.setFrame(BlockBorder.NONE);/*from  ww  w  .j a  v a 2 s  .  c om*/

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("RELEASE_YEAR_TOOLTIP")));

    XYToolTipGenerator generator = new StandardXYToolTipGenerator("{2}", new DecimalFormat("0.00"),
            new DecimalFormat("0.00"));
    renderer.setToolTipGenerator(generator);

    ChartUtilities.applyCurrentTheme(_chart);

    // format the lines after applying the theme
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(1, new BasicStroke(2.0f));
    renderer.setSeriesShape(1, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0));

    _chart.setPadding(new RectangleInsets(10, 10, 10, 10));

    Misc.formatChart(plot);
}

From source file:org.n52.server.io.render.DiagramRenderer.java

protected JFreeChart renderPreChart(Map<String, OXFFeatureCollection> entireCollMap,
        String[] observedProperties, ArrayList<TimeSeriesCollection> timeSeries, Calendar begin, Calendar end) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title
            "Date", // x-axis label
            observedProperties[0], // y-axis label
            timeSeries.get(0), // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );/*from  w ww  .  j a  v  a  2 s.  c o m*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // add additional datasets:
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setRange(begin.getTime(), end.getTime());
    axis.setDateFormatOverride(new SimpleDateFormat());
    axis.setTimeZone(end.getTimeZone());
    for (int i = 1; i < observedProperties.length; i++) {
        XYDataset additionalDataset = timeSeries.get(i);
        plot.setDataset(i, additionalDataset);
        plot.setRangeAxis(i, new NumberAxis(observedProperties[i]));
        // plot.getRangeAxis(i).setRange((Double)
        // overAllSeriesCollection.getMinimum(i),
        // (Double) overAllSeriesCollection.getMaximum(i));
        plot.mapDatasetToRangeAxis(i, i);
        // plot.getDataset().getXValue(i, i);
    }
    return chart;
}

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

/**
 * Creates a chart./*from  ww w  . j  av  a 2  s.  co  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            "Y", // x axis label
            "X", // y axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, !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;

}