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

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

Introduction

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

Prototype

public void setDomainAxis(ValueAxis axis) 

Source Link

Document

Sets the domain axis for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("XYBarChartDemo7", "Date", true, "Y",
            intervalxydataset, PlotOrientation.VERTICAL, true, false, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainAxis(new DateAxis("Date"));
    SymbolAxis symbolaxis = new SymbolAxis("Series", new String[] { "S1", "S2", "S3" });
    symbolaxis.setGridBandsVisible(false);
    xyplot.setRangeAxis(symbolaxis);//w w w  .j  a v  a2s .c  o m
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setUseYInterval(true);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    return jfreechart;
}

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedXYAreaChart("Stacked XY Area Chart Demo 3", "X Value",
            "Y Value", tablexydataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = new DateAxis("Date");
    xyplot.setDomainAxis(dateaxis);
    dateaxis.setLowerMargin(0.0D);// w w  w. j a v  a  2 s .  co  m
    dateaxis.setUpperMargin(0.0D);
    StackedXYAreaRenderer2 stackedxyarearenderer2 = (StackedXYAreaRenderer2) xyplot.getRenderer();
    stackedxyarearenderer2.setRoundXCoordinates(true);
    return jfreechart;
}

From source file:daylightchart.options.chart.BaseChartOptions.java

private static JFreeChart createDummyChart() {
    final JFreeChart chart = new JFreeChart(new XYPlot());
    chart.setTitle("");
    final XYPlot plot = chart.getXYPlot();
    plot.setDomainAxis(new DateAxis());
    plot.setRangeAxis(new DateAxis());
    return chart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Log Axis Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    LogAxis logaxis = new LogAxis("X");
    LogAxis logaxis1 = new LogAxis("Y");
    xyplot.setDomainAxis(logaxis);
    xyplot.setRangeAxis(logaxis1);/*  ww w.  j  ava 2s  .c o  m*/
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("YIntervalChartDemo2", "Date", "Value",
            intervalxydataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainPannable(true);// w w w .  j  a va2 s .  co m
    xyplot.setRangePannable(true);
    xyplot.setDomainAxis(new DateAxis("Date"));
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setAutoRangeIncludesZero(false);
    XYErrorRenderer xyerrorrenderer = new XYErrorRenderer();
    xyerrorrenderer.setBaseLinesVisible(true);
    xyerrorrenderer.setUseFillPaint(true);
    xyerrorrenderer.setBaseFillPaint(Color.white);
    xyplot.setRenderer(xyerrorrenderer);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Logarithmic Axis Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    LogarithmicAxis logarithmicaxis = new LogarithmicAxis("X");
    LogarithmicAxis logarithmicaxis1 = new LogarithmicAxis("Y");
    xyplot.setDomainAxis(logarithmicaxis);
    xyplot.setRangeAxis(logarithmicaxis1);
    return jfreechart;
}

From source file:statistic.graph.gui.Charts.java

private static void initXAxis(XYPlot plot, XYDataset dataset) {
    plot.setDomainAxis(new NumberAxis(plot.getDomainAxis().getLabel()));
    XYSeriesCollection collection = (XYSeriesCollection) dataset;
    double max = Double.NEGATIVE_INFINITY;
    double min = Double.POSITIVE_INFINITY;
    if (collection != null) {
        for (int s = 0; s < collection.getSeriesCount(); s++) {
            for (int d = 0; d < collection.getItemCount(s); d++) {
                XYDataItem data = collection.getSeries(s).getDataItem(d);
                if (data.getX().longValue() == Integer.MAX_VALUE
                        || data.getX().longValue() == Integer.MIN_VALUE) {
                    continue;
                }//from w w w.  j  a va  2  s.c om
                if (data.getX().doubleValue() > max) {
                    max = data.getX().doubleValue();
                }
                if (data.getX().doubleValue() < min) {
                    min = data.getX().doubleValue();
                }
            }
        }
        if (min < max) {
            plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            plot.getDomainAxis().setRange(min - 0.5, max + 0.5);
            for (int s = 0; s < collection.getSeriesCount(); s++) {
                XYSeries series = collection.getSeries(s);
                if (series.indexOf(Integer.MIN_VALUE) >= 0) {
                    XYDataItem item = series.remove((Number) Integer.MIN_VALUE);
                    if (series.indexOf(min) < 0) {
                        series.add(min, item.getY());
                    }
                }
                if (series.indexOf(Integer.MAX_VALUE) >= 0) {
                    XYDataItem item = series.remove((Number) Integer.MAX_VALUE);
                    if (series.indexOf(max) < 0) {
                        series.add(max, item.getY());
                    }
                }
            }
        } else {
            plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            plot.getDomainAxis().setRange(0 - 0.5, 1 + 0.5);
        }
    } else {
        plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        plot.getDomainAxis().setRange(0 - 0.5, 1 + 0.5);
    }
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield",
            xydataset, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15);
    xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime()));
    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);
    }/* ww  w  . j av  a 2 s.c o m*/
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    jfreechart.addSubtitle(new TextTitle("November 2005"));
    TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm");
    texttitle.setFont(new Font("Dialog", 0, 9));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield",
            xydataset, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15);
    xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime()));
    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);
    }/*from www.ja  v a  2 s. c o m*/
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    jfreechart.addSubtitle(new TextTitle("November 2005"));
    TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm");
    texttitle.setFont(new Font("Dialog", 0, 9));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);
    return jfreechart;
}

From source file:osproject.Drawer.java

private static JFreeChart createChart(IntervalXYDataset paramIntervalXYDataset) {
    JFreeChart localJFreeChart = ChartFactory.createXYBarChart("Procssing schadual", "Resource", false,
            "Timing", paramIntervalXYDataset, PlotOrientation.HORIZONTAL, true, false, false);
    localJFreeChart.setBackgroundPaint(Color.BLACK);
    XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();

    SymbolAxis localSymbolAxis = new SymbolAxis("Process", arr);
    localSymbolAxis.setGridBandsVisible(false);
    localXYPlot.setDomainAxis(localSymbolAxis);
    XYBarRenderer localXYBarRenderer = (XYBarRenderer) localXYPlot.getRenderer();
    localXYBarRenderer.setUseYInterval(true);
    localXYPlot.setRangeAxis(new DateAxis("Timing"));
    ChartUtilities.applyCurrentTheme(localJFreeChart);
    return localJFreeChart;
}