Example usage for org.jfree.chart ChartFactory createXYStepAreaChart

List of usage examples for org.jfree.chart ChartFactory createXYStepAreaChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createXYStepAreaChart.

Prototype

public static JFreeChart createXYStepAreaChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a filled stepped XY plot with default settings.

Usage

From source file:com.thecoderscorner.groovychart.chart.XYStepAreaChart.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createXYStepAreaChart(this.getTitle(), this.getXAxisLabel(),
            this.getYAxisLabel(), (XYDataset) this.getDataset(), this.getOrientation(), this.isLegend(),
            this.isTooltips(), this.isUrls());
    return setExtraProperties(chart);

}

From source file:org.radargun.reporting.BarPlotGenerator.java

/**
 * @param operation Name of the plotted operation
 * @param ranges ranges[0] = min, ranges[ranges.length - 1] = max
 * @param counts counts[i] is number of entries with value >= ranges[i - 1] and < ranges[i]
 * @param reportDir/*from   w  ww .ja v  a 2s.com*/
 * @param filename
 * @throws IOException
 */
public static void generate(String operation, long[] ranges, long[] counts, String reportDir, String filename)
        throws IOException {
    XYSeries series = new XYSeries(operation + " response times");
    long totalCount = 0;
    for (long count : counts) {
        totalCount += count;
    }
    double left = Math.log10(ranges[0]);
    double right = Math.log10(ranges[ranges.length - 1]);

    for (int i = 0; i < counts.length; i++) {
        series.add(Math.log10(ranges[i]), (double) counts[i] / totalCount);
    }
    series.add(right, 0d);
    XYDataset dataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYStepAreaChart(operation + " response time histogram",
            "Response time", "Percentage", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis d = (NumberAxis) plot.getDomainAxis();
    d.setRange(left, right);
    d.setStandardTickUnits(new HistoTickUnitSource());
    plot.setDomainAxis(d);
    FileOutputStream output = new FileOutputStream(new File(reportDir + File.separator + filename));
    ChartUtilities.writeChartAsPNG(output, chart, 1024, 768);
    output.close();
}

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

public static JFreeChart createXYStepAreaChart(DiagramData data, XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYStepAreaChart(data.getTitle(), data.getXAxisLabel(),
            data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false);
    initXAxis(chart.getXYPlot(), dataset);
    return chart;
}

From source file:compecon.dashboard.panel.BanksPanel.java

protected ChartPanel createMarketDepthPanel(Currency currency, Currency commodityCurrency) {
    XYDataset dataset = ApplicationContext.getInstance().getModelRegistry()
            .getNationalEconomyModel(currency).marketDepthModel.getMarketDepthDataset(currency,
                    commodityCurrency);/*from  w w w .  j  av a2 s.  co m*/
    JFreeChart chart = ChartFactory.createXYStepAreaChart(commodityCurrency.getIso4217Code() + " Market Depth",
            "Price", "Volume", dataset, PlotOrientation.VERTICAL, true, true, false);
    return new ChartPanel(chart);
}

From source file:org.bench4Q.console.ui.section.LW_ConfigLoadShowSection.java

/**
 * @param args/*  w ww. j av  a2s . c  o  m*/
 * @return
 * @throws IOException
 */
public JPanel drawPreviewPic(Args args) throws IOException {

    XYSeriesCollection dataset = new XYSeriesCollection();

    ArrayList<TestPhase> ebs = args.getEbs();
    int prepairTime = args.getPrepair();
    int cooldownTime = args.getCooldown();

    ArrayList<XYSeries> series = new ArrayList<XYSeries>();
    int i = 1;
    for (TestPhase phase : ebs) {
        XYSeries seriesBasic = new XYSeries("Basic " + i);
        XYSeries seriesRandom = new XYSeries("Random " + i);
        series.add(seriesBasic);
        series.add(seriesRandom);
        int startTime = prepairTime + phase.getTriggerTime();
        int endTime = startTime + phase.getStdyTime();
        int startLoad = phase.getBaseLoad();
        int endLoad = startLoad + phase.getStdyTime() * phase.getRate();
        int startRadomLoad = startLoad + phase.getRandomLoad();
        int endRadomLoad = endLoad + phase.getRandomLoad();

        seriesBasic.add(new Double(startTime), new Integer(0));
        seriesBasic.add(new Double(startTime), new Integer(startLoad));
        seriesBasic.add(new Double(endTime), new Integer(endLoad));
        seriesBasic.add(new Double(endTime), new Integer(0));
        dataset.addSeries(seriesBasic);

        seriesRandom.add(new Double(startTime), new Integer(endLoad));
        seriesRandom.add(new Double(startTime), new Integer(startRadomLoad));
        seriesRandom.add(new Double(endTime), new Integer(endRadomLoad));
        seriesRandom.add(new Double(endTime), new Integer(0));
        dataset.addSeries(seriesRandom);

        i++;

    }

    final JFreeChart chart = ChartFactory.createXYStepAreaChart("Stacked Area Chart", // chart
            // title
            "time", // domain axis label
            "load", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);

    // color
    final XYPlot plot = chart.getXYPlot();

    int j = 0;
    for (XYSeries s : series) {

        if (j % 2 == 0) {
            plot.getRenderer().setSeriesPaint(j, Color.white);
        } else {
            plot.getRenderer().setSeriesPaint(j, Color.gray);
        }
        j++;
    }

    // fill shapes
    final XYStepAreaRenderer rend = (XYStepAreaRenderer) plot.getRenderer();
    rend.setShapesFilled(true);

    return new ChartPanel(chart);
}

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

/**
 * Creates a chart.//from  w  w  w .j av a  2 s.co m
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createXYStepAreaChart("XY Step Area Chart Demo", "Domain (X)",
            "Range (Y)", dataset, PlotOrientation.VERTICAL, true, // legend
            true, // tool tips
            false // URLs
    );

    // color
    final XYPlot plot = chart.getXYPlot();
    plot.getRenderer().setSeriesPaint(0, Color.green);

    // fill shapes      
    final XYStepAreaRenderer rend = (XYStepAreaRenderer) plot.getRenderer();
    rend.setShapesFilled(true);

    return chart;
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java

private static JFreeChart createXYStepAreaChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYStepAreaChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URLs?
    );//from   w  ww  .j  a  va2  s  .c o m

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;
}

From source file:compecon.dashboard.panel.IndustriesPanel.java

protected ChartPanel createMarketDepthPanel(Currency currency, GoodType goodType) {
    XYDataset dataset = ApplicationContext.getInstance().getModelRegistry()
            .getNationalEconomyModel(currency).marketDepthModel.getMarketDepthDataset(currency, goodType);
    JFreeChart chart = ChartFactory.createXYStepAreaChart(goodType + " Market Depth", "Price", "Volume",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    return new ChartPanel(chart);
}

From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java

public static JFreeChart createChartWithXYDataSet(ChartData chartData) {
    XYDataset dataset = (XYDataset) chartData.getDatasource();
    String type = chartData.getType();
    String xAxis = chartData.getXlabel();
    String yAxis = chartData.getYlabel();
    boolean legend = chartData.isLegend();

    JFreeChart chart = null;/*from  ww  w .jav  a 2  s .c  om*/
    PlotOrientation plotOrientation = ChartUtils.getPlotOrientation(chartData.getOrientation());

    if (type.equalsIgnoreCase("timeseries")) {
        chart = ChartFactory.createTimeSeriesChart("", xAxis, yAxis, dataset, legend, true, false);
    } else if (type.equalsIgnoreCase("xyline")) {
        chart = ChartFactory.createXYLineChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("polar")) {
        chart = ChartFactory.createPolarChart("", dataset, legend, true, false);
    } else if (type.equalsIgnoreCase("scatter")) {
        chart = ChartFactory.createScatterPlot("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("xyarea")) {
        chart = ChartFactory.createXYAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("xysteparea")) {
        chart = ChartFactory.createXYStepAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true,
                false);
    } else if (type.equalsIgnoreCase("xystep")) {
        chart = ChartFactory.createXYStepChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("bubble")) {
        chart = ChartFactory.createBubbleChart("", xAxis, yAxis, (XYZDataset) dataset, plotOrientation, legend,
                true, false);
    } else if (type.equalsIgnoreCase("candlestick")) {
        chart = ChartFactory.createCandlestickChart("", xAxis, yAxis, (OHLCDataset) dataset, legend);
    } else if (type.equalsIgnoreCase("boxandwhisker")) {
        chart = ChartFactory.createBoxAndWhiskerChart("", xAxis, yAxis, (BoxAndWhiskerXYDataset) dataset,
                legend);
    } else if (type.equalsIgnoreCase("highlow")) {
        chart = ChartFactory.createHighLowChart("", xAxis, yAxis, (OHLCDataset) dataset, legend);
    } else if (type.equalsIgnoreCase("histogram")) {
        chart = ChartFactory.createHistogram("", xAxis, yAxis, (IntervalXYDataset) dataset, plotOrientation,
                legend, true, false);
    } else if (type.equalsIgnoreCase("wind")) {
        chart = ChartFactory.createWindPlot("", xAxis, yAxis, (WindDataset) dataset, legend, true, false);
    }

    if (chart.getPlot() instanceof XYPlot) {
        chart.getXYPlot().setDomainGridlinesVisible(chartData.isDomainGridLines());
        chart.getXYPlot().setRangeGridlinesVisible(chartData.isRangeGridLines());

        if (chartData.getGenerateMap() != null)
            chart.getXYPlot().getRenderer().setURLGenerator(new StandardXYURLGenerator(""));
    }

    setXYSeriesColors(chart, chartData);

    setXYExtensions(chart, chartData);

    return chart;
}

From source file:compecon.dashboard.panel.HouseholdsPanel.java

protected ChartPanel createMarketDepthPanel(Currency currency) {
    XYDataset dataset = ApplicationContext.getInstance().getModelRegistry()
            .getNationalEconomyModel(currency).marketDepthModel.getMarketDepthDataset(currency,
                    GoodType.LABOURHOUR);
    JFreeChart chart = ChartFactory.createXYStepAreaChart(GoodType.LABOURHOUR + " Market Depth", "Price",
            "Volume", dataset, PlotOrientation.VERTICAL, true, true, false);
    return new ChartPanel(chart);
}