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

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

Introduction

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

Prototype

public void mapDatasetToDomainAxis(int index, int axisIndex) 

Source Link

Document

Maps a dataset to a particular domain axis.

Usage

From source file:org.jfree.chart.demo.CompareToPreviousYearDemo.java

private static JFreeChart createChart() {
    XYDataset xydataset = createDataset2006();
    XYDataset xydataset1 = createDataset2007();
    DateAxis dateaxis = new DateAxis("Date");
    Month month = new Month(1, 2007);
    Month month1 = new Month(12, 2007);
    dateaxis.setRange(month.getFirstMillisecond(), month1.getLastMillisecond());
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM"));
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
    xylineandshaperenderer.setUseFillPaint(true);
    xylineandshaperenderer.setBaseFillPaint(Color.white);
    xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}",
            new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00")));
    XYPlot xyplot = new XYPlot(xydataset1, dateaxis, new NumberAxis("Sales"), xylineandshaperenderer);
    xyplot.setDomainPannable(true);/*from ww  w . ja v a  2s  .co m*/
    xyplot.setRangePannable(true);
    DateAxis dateaxis1 = new DateAxis();
    dateaxis1.setVisible(false);
    xyplot.setDomainAxis(1, dateaxis1);
    xyplot.setDataset(1, xydataset);
    xyplot.mapDatasetToDomainAxis(1, 1);
    XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer();
    xylineandshaperenderer1.setSeriesPaint(0, Color.blue);
    xylineandshaperenderer1.setUseFillPaint(true);
    xylineandshaperenderer1.setBaseFillPaint(Color.white);
    xylineandshaperenderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}",
            new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00")));
    xyplot.setRenderer(1, xylineandshaperenderer1);
    JFreeChart jfreechart = new JFreeChart("Sales Comparison Chart", xyplot);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    DateAxis dateaxis2 = (DateAxis) xyplot.getDomainAxis();
    dateaxis2.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

From source file:ec.nbdemetra.ui.chart3d.functions.Functions2DChart.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    plot.setDataset(0, Charts.emptyXYDataset());
    plot.setRenderer(0, functionRenderer);
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);/*  w  w  w. ja v  a2 s .c  o  m*/

    plot.setDataset(1, Charts.emptyXYDataset());
    plot.setRenderer(1, optimumRenderer);
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false);

    LegendTitle legend = new LegendTitle(result.getPlot());
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    result.addLegend(legend);

    result.setPadding(TsCharts.CHART_PADDING);
    return result;
}

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);/*from www . j  a  va  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;
}

From source file:org.ow2.clif.jenkins.chart.MovingStatChart.java

private void attachThroughputDatasetToDedicatedAxis(XYSeriesCollection throughputDataset, XYPlot plot) {
    NumberAxis throughputAxis = new NumberAxis(Messages.MovingChart_Throughput());
    plot.setRangeAxis(1, throughputAxis);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    plot.setDataset(1, throughputDataset);
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 1);//from   ww w . j  a  v  a 2  s .c om
}

From source file:com.trivadis.loganalysis.ui.ChartPanel.java

private void add(final Serie serie) {
    if (!isDisposed()) {
        serie.setIndex(seriesSequence.get());
        final XYSeriesCollection dataset = new XYSeriesCollection(datasetProvider.getDataset(jvm, serie));
        final int index = serie.getIndex();
        final XYPlot plot = (XYPlot) jfreeChart.getPlot();
        final Color color = getColor(index);
        removeDataset(index, plot);/*  ww  w .j  a  va 2  s. co m*/
        plot.setDataset(index, dataset);
        plot.setRangeAxis(index, axis(color, serie.getYaxis().getValueProvider().getUnit()));
        plot.setDomainAxis(index, axis(color, serie.getXaxis().getValueProvider().getUnit()));
        plot.mapDatasetToDomainAxis(index, index);
        plot.mapDatasetToRangeAxis(index, index);
        plot.setRenderer(index, getRenderer(color, serie.isDotted()));
        seriesSequence.incrementAndGet();
    }
}

From source file:ec.ui.view.StabilityView.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    plot.setDataset(SMOOTH_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(SMOOTH_INDEX, smoothRenderer);
    plot.mapDatasetToDomainAxis(SMOOTH_INDEX, 0);
    plot.mapDatasetToRangeAxis(SMOOTH_INDEX, 0);

    plot.setDataset(MEAN_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(MEAN_INDEX, meanRenderer);
    plot.mapDatasetToDomainAxis(MEAN_INDEX, 0);
    plot.mapDatasetToRangeAxis(MEAN_INDEX, 0);

    plot.setDataset(POINTS_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(POINTS_INDEX, pointsRenderer);
    plot.mapDatasetToDomainAxis(POINTS_INDEX, 0);
    plot.mapDatasetToRangeAxis(POINTS_INDEX, 0);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false);
    result.setPadding(TsCharts.CHART_PADDING);
    return result;
}

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    plot.setDataset(TRUE_DATA_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(TRUE_DATA_INDEX, trueDataRenderer);
    plot.mapDatasetToDomainAxis(TRUE_DATA_INDEX, 0);
    plot.mapDatasetToRangeAxis(TRUE_DATA_INDEX, 0);

    plot.setDataset(FCTS_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(FCTS_INDEX, forecastsRenderer);
    plot.mapDatasetToDomainAxis(FCTS_INDEX, 0);
    plot.mapDatasetToRangeAxis(FCTS_INDEX, 0);

    plot.setDataset(ARIMA_DATA_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(ARIMA_DATA_INDEX, arimaRenderer);
    plot.mapDatasetToDomainAxis(ARIMA_DATA_INDEX, 0);
    plot.mapDatasetToRangeAxis(ARIMA_DATA_INDEX, 0);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false);
    result.setPadding(TsCharts.CHART_PADDING);
    return result;
}

From source file:com.bdb.weather.display.freeplot.FreePlotSeriesCollection.java

/**
 * Constructor.//from   w w w.j  a v a 2s . c o  m
 * 
 * @param groupName The name of this group
 * @param units The units of this collection, used to setup the Range Axis
 * @param datasetIndex The dataset index from a JFreePlot perspective
 * @param domainAxisIndex The index of the domain axis, from a JFreeChart perspective
 * @param plot The plot to which the dataset and axis will be added
 * @param stroke The Stroke used to draw the series of this collection
 * @param factory The factory used to create the series
 */
FreePlotSeriesCollection(String groupName, Unit units, int datasetIndex, int domainAxisIndex, XYPlot plot,
        Stroke stroke, SeriesFactory<T> factory) {
    this.groupName = groupName;
    this.dataset = new TimeSeriesCollection();
    this.datasetIndex = datasetIndex;
    this.factory = factory;
    this.plot = plot;
    renderer = new DefaultXYItemRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    renderer.setDrawSeriesLineAsPath(true);
    plot.setDataset(datasetIndex, dataset);
    plot.setRenderer(datasetIndex, renderer);
    series = factory.createSeriesGroup(groupName, stroke);
    plot.mapDatasetToDomainAxis(datasetIndex, domainAxisIndex);
}

From source file:be.nbb.demetra.dfm.output.simulation.RMSEGraphView.java

private JFreeChart createChart() {
    JFreeChart result = ChartFactory.createXYBarChart("", "", false, "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);
    result.getTitle().setFont(TsCharts.CHART_TITLE_FONT);

    XYPlot plot = result.getXYPlot();

    plot.setDataset(DFM_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(DFM_INDEX, dfmRenderer);
    plot.mapDatasetToDomainAxis(DFM_INDEX, 0);
    plot.mapDatasetToRangeAxis(DFM_INDEX, 0);

    plot.setDataset(ARIMA_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(ARIMA_INDEX, arimaRenderer);
    plot.mapDatasetToDomainAxis(ARIMA_INDEX, 0);
    plot.mapDatasetToRangeAxis(ARIMA_INDEX, 0);

    plot.setDataset(STDEV_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(STDEV_INDEX, stdevRenderer);
    plot.mapDatasetToDomainAxis(STDEV_INDEX, 0);
    plot.mapDatasetToRangeAxis(STDEV_INDEX, 0);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);/*from   ww w .j a  v a 2 s . c  o  m*/

    NumberAxis domainAxis = new NumberAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    return result;
}

From source file:ec.ui.view.DistributionView.java

private static JFreeChart createDistributionViewChart() {
    XYPlot plot = new XYPlot();

    XYLineAndShapeRenderer dRenderer = new XYSplineRenderer();
    dRenderer.setBaseShapesVisible(false);
    dRenderer.setAutoPopulateSeriesPaint(false);
    dRenderer.setAutoPopulateSeriesStroke(false);
    dRenderer.setBaseStroke(TsCharts.getStrongStroke(LinesThickness.Thin));
    dRenderer.setDrawSeriesLineAsPath(true); // not sure if useful
    plot.setDataset(DISTRIBUTION_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(DISTRIBUTION_INDEX, dRenderer);

    XYBarRenderer hRenderer = new XYBarRenderer();
    hRenderer.setShadowVisible(false);/*www .  ja v  a  2 s.co  m*/
    hRenderer.setDrawBarOutline(true);
    hRenderer.setAutoPopulateSeriesPaint(false);
    hRenderer.setAutoPopulateSeriesOutlinePaint(false);
    hRenderer.setBaseSeriesVisibleInLegend(false);
    plot.setDataset(HISTOGRAM_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(HISTOGRAM_INDEX, hRenderer);

    NumberAxis domainAxis = new NumberAxis();
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);
    plot.setDomainGridlinesVisible(false);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    rangeAxis.setTickUnit(new NumberTickUnit(0.05));
    rangeAxis.setNumberFormatOverride(new DecimalFormat("0.###"));
    plot.setRangeAxis(rangeAxis);

    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);

    JFreeChart result = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    result.setPadding(TsCharts.CHART_PADDING);
    result.getTitle().setFont(TsCharts.CHART_TITLE_FONT);
    result.getLegend().setFrame(BlockBorder.NONE);
    result.getLegend().setBackgroundPaint(null);
    return result;
}