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

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

Introduction

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

Prototype

public void setRangeAxis(ValueAxis axis) 

Source Link

Document

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

Usage

From source file:uk.co.petertribble.jkstat.demo.JLoadChart.java

/**
 * A standalone demo charting load averages.
 *//*ww  w.j a va 2  s  .  co  m*/
public JLoadChart() {
    super("JLoadChart");

    jkstat = new NativeJKstat();
    int maxage = 600000;

    String lavetext = KstatResources.getString("LOAD.AVERAGE.TEXT");
    ts1 = new TimeSeries("1min " + lavetext);
    ts1.setMaximumItemAge(maxage);
    ts5 = new TimeSeries("5min " + lavetext);
    ts5.setMaximumItemAge(maxage);
    ts15 = new TimeSeries("15min " + lavetext);
    ts15.setMaximumItemAge(maxage);

    updateAccessory();
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(ts1);
    dataset.addSeries(ts5);
    dataset.addSeries(ts15);

    JFreeChart chart = ChartFactory.createTimeSeriesChart(lavetext, KstatResources.getString("CHART.TIME"),
            KstatResources.getString("LOAD.LOAD.TEXT"), dataset, true, true, false);

    XYPlot xyplot = chart.getXYPlot();

    NumberAxis loadaxis = new NumberAxis(KstatResources.getString("LOAD.LOAD.TEXT"));
    loadaxis.setAutoRange(true);
    loadaxis.setAutoRangeIncludesZero(true);
    xyplot.setRangeAxis(loadaxis);

    DateAxis daxis = new DateAxis(KstatResources.getString("CHART.TIME"));
    daxis.setAutoRange(true);
    daxis.setFixedAutoRange(maxage);
    xyplot.setDomainAxis(daxis);

    addWindowListener(new winExit());
    setContentPane(new ChartPanel(chart));

    JMenuBar jm = new JMenuBar();
    JMenu jme = new JMenu(KstatResources.getString("FILE.TEXT"));
    jme.setMnemonic(KeyEvent.VK_F);
    exitItem = new JMenuItem(KstatResources.getString("FILE.EXIT.TEXT"), KeyEvent.VK_X);
    exitItem.addActionListener(this);
    jme.add(exitItem);
    jm.add(jme);

    setJMenuBar(jm);

    pack();
    setVisible(true);
    Timer timer = new Timer(5000, this);
    timer.start();
}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsModeGroupChart.java

@Override
public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);//  w  w w  . j a v  a  2  s . c o  m
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(0, this.dataset);
    for (int i = 0; i <= 3; i++) {
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:daylightchart.sunchart.chart.SunChart.java

private void createAltitudeAxis(final XYPlot plot) {
    final NumberAxis axis = new NumberAxis();
    axis.setTickLabelFont(ChartConfiguration.chartFont.deriveFont(Font.PLAIN, 12));
    ////from   w w  w  . j  a va 2s . c  o  m
    plot.setRangeAxis(axis);
}

From source file:playground.dgrether.analysis.charts.DgMixedDeltaUtilsModeGroupChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);//  w ww.j  a  v a2  s  .  co m
    plot.setRangeAxis(yAxis);
    //RANGE
    xAxis.setRange(0.0, 102.0);
    yAxis.setRange(-0.31, 0.61);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, colorScheme.COLOR1B);
    renderer1.setSeriesPaint(1, colorScheme.COLOR2B);
    renderer1.setSeriesPaint(2, colorScheme.COLOR3B);
    renderer1.setSeriesPaint(3, colorScheme.COLOR4B);
    plot.setDataset(0, this.inomeModeChoiceDs);
    plot.setRenderer(0, renderer1);

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(1, this.avgDeltaScoreIncomeDs);
    for (int i = 0; i <= 3; i++) {
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(1, renderer2);
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:bzstats.chart.KillRatioHistoryChart.java

protected JFreeChart getChart() {

    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    fillDataset(dataset);/*from w w w .ja v a 2  s .co  m*/

    XYPlot plot = new XYPlot();

    NumberAxis xaxis = new NumberAxis("Time");
    xaxis.setTickLabelsVisible(false);
    NumberAxis yaxis = new NumberAxis("Killratio");

    plot.setDomainAxis(xaxis);
    plot.setRangeAxis(yaxis);
    plot.setDataset(dataset);
    plot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES));

    JFreeChart chart = new JFreeChart("Killratio", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.addSubtitle(new TextTitle("kills/deaths"));

    chart.setBackgroundPaint(Color.white);

    return chart;

}

From source file:grafix.graficos.eixos.Eixo.java

protected void configurarPlot(final XYPlot plot) {
    NumberAxis nAxis = definirEixoVertical();
    plot.setRangeAxis(nAxis);
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinesVisible(this.isGradeHorizontal());
    plot.setRangeGridlinePaint(this.getCorGradeHorizontal());
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    incluirLegenda(plot);//from   ww  w .  j  ava  2 s.c o m
    incluirEixoX(plot);
    configurarEscalaVertical(plot);
}

From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.TimeSeriesChart.java

@Override
protected JFreeChart createGraph() {
    TimeTableXYDataset dataset = createDataset();
    ValueAxis xAxis = new DateAxis();
    xAxis.setLowerMargin(0.0);/*from   w  ww .  j  ava2 s . c  om*/
    xAxis.setUpperMargin(0.0);
    Calendar lowerBound = getLowerGraphBound();
    xAxis.setRange(lowerBound.getTimeInMillis(), Calendar.getInstance().getTimeInMillis());

    NumberAxis yAxis = new NumberAxis(Y_AXIS_LABEL);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    StackedXYBarRenderer renderer = new StackedXYBarRenderer();
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            String seriesKey = dataset.getSeriesKey(series).toString();
            StringBuilder sb = new StringBuilder();

            if (seriesKey.equals(GRAPH_OTHERS)) {
                long timeInMillis = dataset.getX(series, item).longValue();
                Date time = new Date(timeInMillis);

                TimePeriod period = null;
                if (intervalSize == Calendar.DATE) {
                    period = new Day(time);
                } else if (intervalSize == Calendar.HOUR_OF_DAY) {
                    period = new Hour(time);
                } else if (intervalSize == Calendar.MONTH) {
                    period = new Month(time);
                }
                List<FailureCauseTimeInterval> excludedDataList = excludedDataForPeriod.get(period);
                if (excludedDataList != null) {
                    Collections.sort(excludedDataList, new Comparator<FailureCauseTimeInterval>() {

                        @Override
                        public int compare(FailureCauseTimeInterval o1, FailureCauseTimeInterval o2) {
                            return o2.getNumber() - o1.getNumber();
                        }
                    });
                    for (FailureCauseTimeInterval excludedData : excludedDataList) {
                        sb.append(excludedData).append(" \n");
                    }
                }
            } else {
                int number = dataset.getY(series, item).intValue();
                sb.append(seriesKey).append(": ").append(number);
            }
            return sb.toString();
        }
    });

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);

    plot.setRangeAxis(yAxis);

    JFreeChart chart = new JFreeChart(graphTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    return chart;
}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaMoneyGroupChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Money [Chf]");
    plot.setDomainAxis(xAxis);// w  w  w.  ja va  2  s . co m
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    renderer2.setSeriesItemLabelsVisible(0, true);
    renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, this.dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:org.matsim.core.utils.charts.XYScatterChart.java

private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel,
        final XYSeriesCollection dataset) {
    JFreeChart c = ChartFactory.createScatterPlot(title, categoryAxisLabel, valueAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, // legend?
            false, // tooltips?
            false // URLs?
    );/*from  w w w .j  a  v a  2s  . c  o  m*/
    if (this.isLogarithmicAxis) {
        XYPlot p = (XYPlot) c.getPlot();
        LogarithmicAxis axis_x = new LogarithmicAxis(this.xAxisLabel);
        LogarithmicAxis axis_y = new LogarithmicAxis(this.yAxisLabel);
        axis_x.setAllowNegativesFlag(false);
        axis_y.setAllowNegativesFlag(false);
        p.setDomainAxis(axis_x);
        p.setRangeAxis(axis_y);
    }
    return c;
}

From source file:org.matsim.core.utils.charts.XYLineChart.java

private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel,
        final XYSeriesCollection dataset) {
    JFreeChart c = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, // legend?
            false, // tooltips?
            false // URLs?
    );//  w  w  w.j  a  v a  2  s. co m
    if (this.isLogarithmicAxis) {
        XYPlot p = (XYPlot) c.getPlot();
        LogarithmicAxis axis_x = new LogarithmicAxis(this.xAxisLabel);
        LogarithmicAxis axis_y = new LogarithmicAxis(this.yAxisLabel);
        axis_x.setAllowNegativesFlag(false);
        axis_y.setAllowNegativesFlag(false);
        p.setDomainAxis(axis_x);
        p.setRangeAxis(axis_y);
    }
    return c;
}