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:com.ivli.roim.controls.ChartView.java

protected void initChart() {
    if (null != iPlot) {
        ((XYSeriesCollection) iPlot.getDataset()).removeAllSeries();
    } else {/*w  ww  . j  a va2s.  c o m*/
        iPlot = new XYPlot();
        iPlot.setRenderer(new StandardXYItemRenderer());
        iPlot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
                .getString("ROI_CHART.TIME_SERIES_VALUES")));
        iPlot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
                .getString("ROI_CHART.ROI_INTDEN_VALUES")));
        iPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
        iPlot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

        iJfc = new JFreeChart(
                java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("ROI_CHART.CHART_TITLE"),
                iPlot);

        iChart = new ChartControl(iJfc);

        iPlot.setDataset(new XYSeriesCollection());

        iChart.setPreferredSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
        iChart.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
        setLayout(new BorderLayout());

        this.add(iChart);
    }
    iChart.setMouseZoomable(false);
    iChart.setMouseWheelEnabled(true);
}

From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java

public static JFreeChart createOverlaidChart(SuccessfulAttack sa) {

    // create subplot 1...
    final XYSeries data1 = createDatasetResponseTime(RequestType.UNTAMPERED, sa.getUntamperedMetrics());
    final XYSeries data2 = createDatasetResponseTime(RequestType.TAMPERED, sa.getTamperedMetrics());
    final XYSeries data3 = createDatasetResponseTime(RequestType.TESTPROBES, sa.getTestProbes());

    final XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(data1);//from w  ww. j  av  a2 s .co  m
    collection.addSeries(data2);
    collection.addSeries(data3);

    final XYItemRenderer renderer = new StandardXYItemRenderer();
    final NumberAxis rangeAxis1 = new NumberAxis("duration in ms");
    final XYPlot plot = new XYPlot(collection, new NumberAxis(""), rangeAxis1, renderer);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    renderer.setSeriesPaint(0, Color.GREEN);
    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesPaint(2, Color.BLUE);

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

From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java

/**
 * Creates the main chart, but does not fill inn any data
 *//*from  ww  w .j a  v a 2 s.c  o m*/
private void createChart() {
    JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Period", // x axis label
            "Discounted Cash", // y axis label
            null, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    plot.getDomainAxis().setTickMarksVisible(false);

    setChart(chart);
    setMouseZoomable(false);
}

From source file:openqcm.ChartDynamicData.java

public ChartDynamicData() {

    // add primary axis frequency
    TimeSeries seriesFrequency = new TimeSeries("Frequency (Hz)");
    datasetFrequency = new TimeSeriesCollection(seriesFrequency);
    rangeAxisF = new NumberAxis("Frequency (Hz)");
    XYItemRenderer renderer = new StandardXYItemRenderer();
    renderer.setSeriesPaint(0, new Color(0, 142, 192));
    rangeAxisF.setAutoRangeIncludesZero(false);
    rangeAxisF.setAutoRange(true);/*from ww w  .j ava  2  s . c o m*/
    rangeAxisF.setAutoRangeMinimumSize(50);

    plot.setDataset(0, datasetFrequency);
    plot.setRangeAxis(0, rangeAxisF);
    plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
    plot.setRenderer(0, renderer);
    plot.mapDatasetToRangeAxis(0, 0);

    // add secondary axis temperature
    TimeSeries seriesTemperature = new TimeSeries("Temperature (C)");
    datasetTemperature = new TimeSeriesCollection(seriesTemperature);
    plot.setDataset(1, datasetTemperature);
    NumberAxis rangeAxisT = new NumberAxis("Temperature (C)");
    rangeAxisT.setAutoRangeIncludesZero(false);
    rangeAxisT.setAutoRange(true);
    rangeAxisT.setAutoRangeMinimumSize(5);
    plot.setRangeAxis(1, rangeAxisT);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    // custom renderer for dinamically changing temperaure
    rendererT.setSeriesPaint(0, new Color(255, 128, 0));
    plot.setRenderer(1, rendererT);

    plot.mapDatasetToRangeAxis(1, 1);
    plotComb.add(plot);
    plotComb.setBackgroundPaint(Color.white);
    plotComb.setDomainGridlinePaint(Color.white);
    plotComb.setRangeGridlinePaint(Color.white);
    // enable panning for both axis
    plotComb.setRangePannable(true);
    plotComb.setDomainPannable(true);

    // set time axis properties
    // format time axis as hh:mm:ss
    SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
    DateAxis axis = (DateAxis) plotComb.getDomainAxis();
    axis.setDateFormatOverride(format);
    // default auto range
    domainAxis.setAutoRange(true);

    // init the JFreeChart
    JFreeChart chart = new JFreeChart(plotComb);
    chart.setBorderPaint(Color.lightGray);
    chart.setBorderVisible(true);
    chart.setBackgroundPaint(Color.white);

    // set legend properties
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.TOP);
    legend.setItemFont(new Font("Dialog", Font.PLAIN, 9));

    // constructor for org.jfree.chart.ChartPanel
    // ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)
    ChartPanel chartPanel = new ChartPanel(chart, false, true, true, true, true);
    // enable mouse wheel support for the chart panel
    chartPanel.setMouseWheelEnabled(true);

    this.setLayout(new BorderLayout());
    // add real time chart to the frame
    this.add(chartPanel);
    this.validate();
}

From source file:com.googlecode.logVisualizer.chart.VerticalXYBarChartBuilder.java

private JFreeChart createChart(final IntervalXYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYBarChart(getTitle(), xLable, false, yLable, dataset,
            PlotOrientation.VERTICAL, isIncludeLegend(), true, false);
    final XYPlot plot = (XYPlot) chart.getPlot();
    final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();

    double lastXValue = 0;
    if (dataset.getSeriesCount() > 0)
        lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1);

    plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue));
    plot.setNoDataMessage("No data available");
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.black);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    setBarShadowVisible(chart, false);/* www.j a  v a2  s.co  m*/

    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    if (dataset.getSeriesCount() > 0)
        plot.getDomainAxis().setUpperBound(lastXValue);
    plot.getDomainAxis().setLowerBound(0);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setUpperMargin(0.1);

    return chart;
}

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

private XYPlot createThroughputPlot(ResourceBundle bundle, ReportConfig config) {
    TimeSeriesCollection dataset1 = createThroughputDataset(bundle, config);
    XYPlot throughputPlot = ChartUtil.newPlot(dataset1, bundle.getString("chronos.label.throughput.requests"),
            true);/*from   w w  w  .ja v  a2 s. c om*/
    throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    throughputPlot.getRenderer().setSeriesPaint(0, Color.GREEN);
    throughputPlot.getRenderer().setSeriesPaint(1, Color.BLUE);
    throughputPlot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    double maxAvgThroughput = samples.getMaxAverageThroughput(config.getAverageduration(),
            config.getResponsetimedivider());
    String maxThroughputLabel = bundle.getString("chronos.label.maxaveragethroughput");
    ChartUtil.addRangeMarker(throughputPlot, maxThroughputLabel, maxAvgThroughput);
    return throughputPlot;
}

From source file:com.opensourcestrategies.crmsfa.reports.JFreeCrmsfaCharts.java

/**
 * Lead pipeline.  Description at http://www.opentaps.org/docs/index.php/CRMSFA_Dashboard
 * Note that this counts all the leads in the system for now.
 *///www  .j  av  a2  s  .  c o m
public static String createLeadPipelineChart(Delegator delegator, Locale locale)
        throws GenericEntityException, IOException {
    Map uiLabelMap = UtilMessage.getUiLabels(locale);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    // get all LEAD statuses that are not CONVERTED, or DEAD
    List<GenericValue> leadStatuses = ReportHelper.findLeadStatusesForDashboardReporting(delegator);

    // report number of leads for each status
    for (GenericValue status : leadStatuses) {
        String statusId = status.getString("statusId");
        long count = delegator.findCountByCondition("PartyAndStatus",
                EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, statusId), null);
        dataset.addValue(count, "", (String) status.get("description", locale));
    }

    // set up the chart
    JFreeChart chart = ChartFactory.createBarChart((String) uiLabelMap.get("CrmLeadPipeline"), null, null,
            dataset, PlotOrientation.HORIZONTAL, false, true, false);
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

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

    // get the bar renderer to put effects on the bars
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false); // disable bar outlines

    // set up gradient paint on bar
    final GradientPaint gp = new GradientPaint(0.0f, 0.0f, new Color(227, 246, 206), 0.0f, 0.0f,
            new Color(153, 204, 102));
    renderer.setSeriesPaint(0, gp);

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

    // save as a png and return the file name
    return ServletUtilities.saveChartAsPNG(chart, 360, 200, null);
}

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

public final void createThroughputChart(HistoricSamples samples, String dataId) throws IOException {
    XYPlot xyplot = newPlot(samples.getThroughput(dataId), "chronos.label.throughput.requests", true);
    xyplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    xyplot.getRenderer().setSeriesPaint(0, Color.GREEN);

    String timeLabel = bundle.getString("chronos.label.throughput.historytime");
    DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat());
    xyplot.setDomainAxis(timeAxis);/*from   ww w.  jav a 2s. com*/
    JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.throughput"), xyplot);
    renderer.renderChart("history-throughput-" + dataId, chart);
}

From source file:org.jstockchart.area.VolumeArea.java

/**
 * Returns the volume axis location that is determined by the plot
 * orientation./*  w w w . j a  va 2 s . co  m*/
 * 
 * @return the volume axis location.
 */
public AxisLocation getVolumeAxisLocation() {
    PlotOrientation orientation = getOrientation();
    AxisLocation result = null;
    if (orientation.equals(PlotOrientation.VERTICAL)) {
        result = AxisLocation.BOTTOM_OR_LEFT;
    } else if (orientation.equals(PlotOrientation.HORIZONTAL)) {
        result = AxisLocation.TOP_OR_RIGHT;
    }

    return result;
}

From source file:org.jfree.chart.swt.demo.SWTMultipleAxisDemo1.java

/**
 * Creates the demo chart.// w  w w .ja  v  a2 s .c  o  m
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

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

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

    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setBorderPaint(Color.BLACK);
    TextTitle subtitle = new TextTitle("Four datasets and four range axes.");
    chart.addSubtitle(subtitle);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);

    // AXIS 2
    NumberAxis axis2 = new NumberAxis("Range Axis 2");
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);

    // AXIS 3
    NumberAxis axis3 = new NumberAxis("Range Axis 3");
    axis3.setLabelPaint(Color.blue);
    axis3.setTickLabelPaint(Color.blue);
    //axis3.setPositiveArrowVisible(true);
    plot.setRangeAxis(2, axis3);

    XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170);
    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 2);
    XYItemRenderer renderer3 = new StandardXYItemRenderer();
    renderer3.setSeriesPaint(0, Color.blue);
    plot.setRenderer(2, renderer3);

    // AXIS 4
    NumberAxis axis4 = new NumberAxis("Range Axis 4");
    axis4.setLabelPaint(Color.green);
    axis4.setTickLabelPaint(Color.green);
    plot.setRangeAxis(3, axis4);

    XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200);
    plot.setDataset(3, dataset4);
    plot.mapDatasetToRangeAxis(3, 3);

    XYItemRenderer renderer4 = new StandardXYItemRenderer();
    renderer4.setSeriesPaint(0, Color.green);
    plot.setRenderer(3, renderer4);

    return chart;
}