Example usage for org.jfree.chart.axis AxisLocation BOTTOM_OR_LEFT

List of usage examples for org.jfree.chart.axis AxisLocation BOTTOM_OR_LEFT

Introduction

In this page you can find the example usage for org.jfree.chart.axis AxisLocation BOTTOM_OR_LEFT.

Prototype

AxisLocation BOTTOM_OR_LEFT

To view the source code for org.jfree.chart.axis AxisLocation BOTTOM_OR_LEFT.

Click Source Link

Document

Axis at the bottom or left.

Usage

From source file:DualAxisDemo4.java

/**
 * Creates a new demo instance./*  w w w. ja v  a  2  s  .  com*/
 *
 * @param title  the frame title.
 */
public DualAxisDemo4(final String title) {

    super(title);

    final CategoryDataset dataset1 = createDataset1();

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart3D("Dual Axis Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset1, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC));
    //        chart.getLegend().setAnchor(Legend.SOUTH);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    final CategoryItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.red);
    renderer1.setSeriesPaint(1, Color.yellow);
    renderer1.setSeriesPaint(2, Color.green);
    final CategoryDataset dataset2 = createDataset2();
    final ValueAxis axis2 = new NumberAxis3D("Secondary");
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    final CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setSeriesPaint(0, Color.blue);
    plot.setRenderer(1, renderer2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:ascensionxyplot.AscensionXYPlot.java

/**
 * Creates a combined chart.//from ww  w  . j a v a 2 s  .com
 *
 * @return The combined chart.
 */
private JFreeChart createCombinedChart(File dataFile) {

    // create subplot 1...
    final XYDataset data1 = createDataset1(dataFile);
    final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // add secondary axis
    //        subplot1.setDataset(1, createDataset2());
    //        final NumberAxis axis2 = new NumberAxis("Range Axis 2");
    //        axis2.setAutoRangeIncludesZero(false);
    //        subplot1.setRangeAxis(1, axis2);
    //        subplot1.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    //        subplot1.setRenderer(1, new StandardXYItemRenderer());       
    //        subplot1.mapDatasetToRangeAxis(1, 1);

    final XYTextAnnotation annotation1 = new XYTextAnnotation("x value", 20.0, 120000.0);
    final XYTextAnnotation annotation2 = new XYTextAnnotation("y value", 20.0, 110000.0);
    final XYTextAnnotation annotation3 = new XYTextAnnotation("z value", 20.0, 100000.0);
    final XYTextAnnotation annotation4 = new XYTextAnnotation("timepoint", 20.0, 10000.0);
    annotation1.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation2.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation3.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation4.setFont(new Font("SansSerif", Font.PLAIN, 9));
    //        annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation1);
    subplot1.addAnnotation(annotation2);
    subplot1.addAnnotation(annotation3);
    subplot1.addAnnotation(annotation4);

    // create subplot 2...
    final XYDataset data2 = createDataset2();
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);

    // return a new chart containing the overlaid plot...
    return new JFreeChart("Is this the title?", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

}

From source file:com.yahoo.egads.utilities.GUIUtils.java

/**
 * Creates a combined chart.//from   www . j  a va 2  s.c om
 *
 * @return The combined chart.
 */
private JFreeChart createCombinedChart(DataSequence tsOne, DataSequence tsTwo, ArrayList<Anomaly> anomalyList) {

    // create subplot 1.
    final XYDataset data1 = createDataset(tsOne, "Original");
    final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis1 = new NumberAxis("Original Value");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // plot anomalies on subplot 1.
    addAnomalies(subplot1, anomalyList);

    // create subplot 2.
    final XYDataset data2 = createDataset(tsTwo, "Forecast");
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis2 = new NumberAxis("Forecast Value");
    rangeAxis2.setAutoRangeIncludesZero(false);
    final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot.
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time"));
    plot.setGap(10.0);

    // add the subplots.
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);

    // Add anomaly score time-series.
    addAnomalyTS(plot, tsOne, tsTwo);

    plot.setOrientation(PlotOrientation.VERTICAL);

    // return a new chart containing the overlaid plot.
    return new JFreeChart("EGADS GUI", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:org.codehaus.mojo.chronos.chart.HistoryChartGenerator.java

public final void createGcChart(HistoricSamples samples, String dataId) throws IOException {
    XYPlot xyplot1 = newPlot(samples.getGcRatio(dataId), "chronos.label.gc.ratio", true);
    xyplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    xyplot1.getRenderer().setSeriesPaint(0, Color.GREEN);
    xyplot1.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits());

    XYPlot xyplot2 = newPlot(samples.getKbCollectedPrSecond(dataId), "chronos.label.gc.kbpersec", true);
    xyplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    xyplot2.getRenderer().setSeriesPaint(0, Color.GRAY);
    xyplot2.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits());

    String timeLabel = bundle.getString("chronos.label.gc.historytime");
    DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat());
    XYPlot combinedPlot = ChartUtil.createCombinedPlot(timeAxis, xyplot1, xyplot2);
    // xyplot1.setDomainAxis( timeAxis );
    // XYPlot combinedPlot = xyplot1;
    JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.gc"), combinedPlot);
    renderer.renderChart("history-gc-" + dataId, chart);
}

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

public void createChart() {

    _chart = ChartFactory.createBarChart3D(Misc.getString("SONG_WORDS"), // chart title
            Misc.getString("WORD"), // domain axis label
            Misc.getString("SONG_COUNT"), // range axis label
            _dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );//from  www  . ja  va 2 s .c o m

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

    CategoryPlot plot = (CategoryPlot) _chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartUtilities.applyCurrentTheme(_chart);
    Misc.formatChart(plot);

    CategoryItemRenderer renderer = plot.getRenderer();
    BarRenderer3D barRenderer = (BarRenderer3D) renderer;
    barRenderer.setWallPaint(Color.white);
    barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]);
}

From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java

public XYPlot drawStandardXYPlot(Shape shape, Color color, int minSignal, int maxSignal) {
    // Set up renderer
    StandardXYItemRenderer batteryRenderer = new StandardXYItemRenderer(
            StandardXYItemRenderer.SHAPES_AND_LINES);
    batteryRenderer.setAutoPopulateSeriesShape(false);
    batteryRenderer.setBaseShape(shape);
    batteryRenderer.setSeriesPaint(0, color);

    // Normalize the throughput axis so that it represents max value
    NumberAxis axis = new NumberAxis();
    axis.setVisible(false);//from   w w  w .  j  ava2 s  . c o m
    axis.setAutoRange(false);
    axis.setRange(minSignal, maxSignal);

    // Create plot
    XYPlot barPlot = new XYPlot(null, null, axis, batteryRenderer);
    barPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    barPlot.getRangeAxis().setVisible(false);

    return barPlot;
}

From source file:org.jrecruiter.web.actions.admin.ShowStatisticsAction.java

private static JFreeChart createChart(final CategoryDataset categorydataset, final String chartTitle) {
    final JFreeChart chart = ChartFactory.createBarChart(chartTitle, "Jobs", "Number of Hits", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");

    chart.setBackgroundPaint(new Color(245, 245, 255));
    chart.setBorderPaint(new Color(204, 204, 204));
    chart.setBorderStroke(new BasicStroke(1f));

    final LegendTitle legend = chart.getLegend();
    legend.setWidth(1000);/*  w  w  w  .  jav a 2  s . co m*/
    legend.setPosition(RectangleEdge.BOTTOM);

    final BlockBorder border = new BlockBorder(new Color(204, 204, 204));
    legend.setBorder(border);

    final CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot();
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(new Color(204, 204, 204));
    categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    final NumberAxis numberaxis = (NumberAxis) categoryPlot.getRangeAxis();

    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    final BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();
    renderer.setDrawBarOutline(true);

    final ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.CENTER);
    renderer.setPositiveItemLabelPosition(itemlabelposition);

    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());

    renderer.setItemLabelsVisible(true);
    return chart;
}

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

/**
 * Creates the demo chart.//from w ww  .j  av a2s .  c o m
 * 
 * @return The chart.
 */
private JFreeChart createChart() {

    final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day",
            "Primary Range Axis", dataset1, true, true, false);

    chart.setBackgroundPaint(Color.white);
    final XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));

    final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    renderer.setPaint(Color.black);

    // DOMAIN AXIS 2
    final NumberAxis xAxis2 = new NumberAxis("Domain Axis 2");
    xAxis2.setAutoRangeIncludesZero(false);
    plot.setDomainAxis(1, xAxis2);
    plot.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    // DOMAIN AXIS 3
    final NumberAxis xAxis3 = new NumberAxis("Domain Axis 3");
    xAxis2.setAutoRangeIncludesZero(false);
    plot.setDomainAxis(2, xAxis3);
    plot.setDomainAxisLocation(2, AxisLocation.BOTTOM_OR_LEFT);

    // RANGE AXIS 2
    final NumberAxis yAxis2 = new NumberAxis("Range Axis 2");
    plot.setRangeAxis(1, yAxis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToDomainAxis(1, 1);
    plot.mapDatasetToRangeAxis(1, 1);

    return chart;

}

From source file:j2se.jfreechart.barchart.BarChartDemo2.java

/**
 * Creates a chart.//from w  w  w . j a  v a2 s  . c om
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 2", // chart title
            "Category", // domain axis label
            "Score (%)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.lightGray);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(0.0, 100.0);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

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

/**
 * Creates a chart.//from  w w  w  . j a va  2s  .  c  om
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 2", // chart title
            "Category", // domain axis label
            "Score (%)", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.lightGray);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(0.0, 100.0);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}