Example usage for org.jfree.chart ChartFactory createXYStepChart

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

Introduction

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

Prototype

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

Source Link

Document

Creates a stepped XY plot with default settings.

Usage

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

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

}

From source file:xdevs.lib.util.ScopeView.java

public ScopeView(String windowsTitle, String title, String xTitle, String yTitle) {
    super(windowsTitle);
    XYSeriesCollection dataSet = new XYSeriesCollection();
    serie = new XYSeries(yTitle);
    dataSet.addSeries(serie);//  ww w.j a  v a 2s. co m
    JFreeChart chart = ChartFactory.createXYStepChart(title, xTitle, yTitle, dataSet, PlotOrientation.VERTICAL,
            true, false, false);
    chart.getXYPlot().setDomainAxis(new NumberAxis());
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });
    super.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}

From source file:xdevs.lib.util.ScopeMultiView.java

public ScopeMultiView(String windowsTitle, String title, String xTitle, String yTitle) {
    super(windowsTitle);
    JFreeChart chart = ChartFactory.createXYStepChart(title, xTitle, yTitle, dataSet, PlotOrientation.VERTICAL,
            true, false, false);/*w  ww . j  av a  2s .com*/
    chart.getXYPlot().setDomainAxis(new NumberAxis());
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });
    super.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}

From source file:org.matsim.analysis.LegHistogramChart.java

static JFreeChart getGraphic(final LegHistogram.DataFrame dataFrame, final String mode, int iteration) {
    final XYSeriesCollection xyData = new XYSeriesCollection();
    final XYSeries departuresSerie = new XYSeries("departures", false, true);
    final XYSeries arrivalsSerie = new XYSeries("arrivals", false, true);
    final XYSeries onRouteSerie = new XYSeries("en route", false, true);
    int onRoute = 0;
    for (int i = 0; i < dataFrame.countsDep.length; i++) {
        onRoute = onRoute + dataFrame.countsDep[i] - dataFrame.countsArr[i] - dataFrame.countsStuck[i];
        double hour = i * dataFrame.binSize / 60.0 / 60.0;
        departuresSerie.add(hour, dataFrame.countsDep[i]);
        arrivalsSerie.add(hour, dataFrame.countsArr[i]);
        onRouteSerie.add(hour, onRoute);
    }//from   w w w .  j a  v  a  2 s.c o  m

    xyData.addSeries(departuresSerie);
    xyData.addSeries(arrivalsSerie);
    xyData.addSeries(onRouteSerie);

    final JFreeChart chart = ChartFactory.createXYStepChart("Leg Histogram, " + mode + ", it." + iteration,
            "time", "# persons", xyData, PlotOrientation.VERTICAL, true, // legend
            false, // tooltips
            false // urls
    );

    XYPlot plot = chart.getXYPlot();

    final CategoryAxis axis1 = new CategoryAxis("hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    plot.setDomainAxis(new NumberAxis("time"));

    plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainGridlinePaint(Color.gray);

    return chart;
}

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

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

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

/**
 * Displays a sample chart in its own frame.
 *///from  ww  w .j a va2  s .c o m
private void displayChart() {

    if (this.frame == null) {

        // create a default chart based on some sample data...
        final String title = "LCACs in use at given time";
        final String xAxisLabel = "Time";
        final String yAxisLabel = "Number of Transports";

        final XYDataset data = createStepXYDataset();

        final JFreeChart chart = ChartFactory.createXYStepChart(title, xAxisLabel, yAxisLabel, data,
                PlotOrientation.VERTICAL, true, // legend
                true, // tooltips
                false // urls
        );

        // then customise it a little...
        chart.setBackgroundPaint(new Color(216, 216, 216));
        final XYPlot plot = chart.getXYPlot();
        plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));
        plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));

        // and present it in a frame...
        this.frame = new ChartFrame("Plan Comparison", chart);
        this.frame.pack();
        RefineryUtilities.positionFrameRandomly(this.frame);
        this.frame.setVisible(true);

    } else {
        this.frame.setVisible(true);
        this.frame.requestFocus();
    }

}

From source file:org.matsim.contrib.socnetsim.usage.analysis.CourtesyHistogramListener.java

static JFreeChart getGraphic(final CourtesyHistogram.DataFrame dataFrame, int iteration, String actType) {
    final XYSeriesCollection xyData = new XYSeriesCollection();
    final XYSeries helloSeries = new XYSeries("hello", false, true);
    final XYSeries goodbyeSerie = new XYSeries("goodbye", false, true);
    final XYSeries togetherSerie = new XYSeries("pairs together", false, true);
    int together = 0;
    for (int i = 0; i < dataFrame.countsHello.length; i++) {
        together = together + dataFrame.countsHello[i] - dataFrame.countsGoodbye[i];
        double hour = i * dataFrame.binSize / 60.0 / 60.0;
        helloSeries.add(hour, dataFrame.countsHello[i]);
        goodbyeSerie.add(hour, dataFrame.countsGoodbye[i]);
        togetherSerie.add(hour, together);
    }/*from   www. j  a v  a2 s.  com*/

    xyData.addSeries(helloSeries);
    xyData.addSeries(goodbyeSerie);
    xyData.addSeries(togetherSerie);

    final JFreeChart chart = ChartFactory.createXYStepChart(
            "Courtesy Statistics," + "actType " + actType + " it." + iteration, "time", "# persons", xyData,
            PlotOrientation.VERTICAL, true, // legend
            false, // tooltips
            false // urls
    );

    XYPlot plot = chart.getXYPlot();

    final CategoryAxis axis1 = new CategoryAxis("hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    plot.setDomainAxis(new NumberAxis("time"));

    plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainGridlinePaint(Color.gray);

    return chart;
}

From source file:net.sf.smbt.ui.btc.views.AbstractBlockchainView.java

public void addCharts(Composite folder) {
    chart = ChartFactory.createXYStepChart(getChartTitle(), getXAxisLabel(), getYAxisLabel(), null,
            PlotOrientation.VERTICAL, true, // legend
            true, // tooltips
            false // urls
    );/*  w ww . j a v  a2 s. c om*/

    // then customise it a little...

    final XYPlot plot = chart.getXYPlot();

    chart.getTitle().setPaint(Color.LIGHT_GRAY);

    chart.setBackgroundPaint(new java.awt.Color(66, 66, 66));
    plot.setBackgroundPaint(new java.awt.Color(66, 66, 66));
    plot.getRenderer().setSeriesVisibleInLegend(false);

    plot.getRangeAxis().setTickLabelPaint(Color.LIGHT_GRAY);
    plot.getRangeAxis().setLabelPaint(Color.LIGHT_GRAY);

    plot.getDomainAxis().setTickLabelPaint(Color.LIGHT_GRAY);
    plot.getDomainAxis().setLabelPaint(Color.LIGHT_GRAY);

    plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));

    // and present it in a frame...

    new ChartComposite(folder, SWT.NONE, chart, true);
}

From source file:playground.dgrether.analysis.categoryhistogram.CategoryHistogramWriter.java

public JFreeChart getGraphic(final CategoryHistogram histo, final String modeName) {
    this.checkIndex(histo);
    final XYSeriesCollection xyData = new XYSeriesCollection();
    final XYSeries departuresSerie = new XYSeries(this.departuresName, false, true);
    final XYSeries arrivalsSerie = new XYSeries(this.arrivalsName, false, true);
    final XYSeries onRouteSerie = new XYSeries(this.enRouteName, false, true);
    Integer enRoute = 0;//from w w  w  . j a va2 s. c om
    for (int i = histo.getFirstIndex() - 2; i <= histo.getLastIndex() + 2; i++) {
        int departures = histo.getDepartures(modeName, i);
        int arrivals = histo.getArrivals(modeName, i);
        int stuck = histo.getAbort(modeName, i);
        enRoute = enRoute + departures - arrivals - stuck;
        double hour = i * histo.getBinSizeSeconds() / 60.0 / 60.0;
        departuresSerie.add(hour, departures);
        arrivalsSerie.add(hour, arrivals);
        onRouteSerie.add(hour, enRoute);
    }
    xyData.addSeries(departuresSerie);
    xyData.addSeries(arrivalsSerie);
    xyData.addSeries(onRouteSerie);

    final JFreeChart chart = ChartFactory.createXYStepChart(
            this.title + ", " + modeName + ", " + "it." + histo.getIteration(), "time [h]", yTitle, xyData,
            PlotOrientation.VERTICAL, true, // legend
            false, // tooltips
            false // urls
    );

    XYPlot plot = chart.getXYPlot();

    final CategoryAxis axis1 = new CategoryAxis("hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    plot.setDomainAxis(new NumberAxis("time"));

    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(1.0f));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainGridlinePaint(Color.gray);

    return chart;
}

From source file:org.cytoscape.dyn.internal.graphMetrics.GenerateChart.java

public JFreeChart generateTimeSeries() {

    dataset = new XYSeriesCollection();
    XYSeries[] attributeSeries = new XYSeries[(selectedNodes.size() + selectedEdges.size())
            * (checkedAttributes.size() + edgeCheckedAttributes.size())];
    int j = 0;/*from w w w  .  ja  va2  s . c om*/
    /*creating dataseries for each node and its checked attribute and
    adding it to the dataset*/
    for (CyNode node : selectedNodes) {
        // System.out.println(checkedAttributes.size());
        for (int i = 0; i < checkedAttributes.size(); i++) {
            attributeSeries[j] = new XYSeries(dynamicNetwork.getNodeLabel(node) + checkedAttributes.get(i),
                    false, true);
            // System.out.println(dynamicNetwork.getDynAttribute(node,
            // checkedAttributes.get(i)).getKey().getColumn());

            for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(node, checkedAttributes.get(i))
                    .getIntervalList()) {
                // System.out.println(interval.getOnValue());
                double value;
                if (interval.getOnValue() instanceof Double)
                    value = (Double) interval.getOnValue();
                else
                    value = ((Integer) interval.getOnValue()).doubleValue();
                // System.out.println(value);
                attributeSeries[j].add(interval.getStart(), value);
                attributeSeries[j].add(interval.getEnd(), value);
                //System.out.println("interval start ="+interval.getStart());
                //System.out.println("interval end ="+interval.getEnd());
                //System.out.println("--------");
            }
            dataset.addSeries(attributeSeries[j++]);
        }
    }
    /*creating dataseries for each edge and its checked attribute and
    adding it to the dataset*/
    for (CyEdge edge : selectedEdges) {
        // System.out.println(checkedAttributes.size());
        for (int i = 0; i < edgeCheckedAttributes.size(); i++) {
            attributeSeries[j] = new XYSeries(dynamicNetwork.getEdgeLabel(edge) + edgeCheckedAttributes.get(i),
                    false, true);
            // System.out.println(dynamicNetwork.getDynAttribute(node,
            // checkedAttributes.get(i)).getKey().getColumn());

            for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(edge, edgeCheckedAttributes.get(i))
                    .getIntervalList()) {
                // System.out.println(interval.getOnValue());
                double value;
                if (interval.getOnValue() instanceof Double)
                    value = (Double) interval.getOnValue();
                else if (interval.getOnValue() instanceof Integer)
                    value = ((Integer) interval.getOnValue()).doubleValue();
                else if (interval.getOnValue() instanceof Short)
                    value = ((Short) interval.getOnValue()).doubleValue();
                else
                    value = ((Long) interval.getOnValue()).doubleValue();
                // System.out.println(value);
                attributeSeries[j].add(interval.getStart(), value);
                attributeSeries[j].add(interval.getEnd(), value);

            }
            dataset.addSeries(attributeSeries[j++]);
        }
    }

    String title = "Dynamic Graph Metrics";
    String xAxisLabel = "Time";
    String yAxisLabel = "Centrality Value";
    JFreeChart chart = ChartFactory.createXYStepChart(title, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, // legend
            true, // tooltips
            false // urls
    );

    NumberAxis xaxis = new NumberAxis();
    xaxis.setAutoRangeMinimumSize(1.0);
    xaxis.setLabel("Time");
    chart.getXYPlot().setDomainAxis(xaxis);
    NumberAxis yaxis = new NumberAxis();
    yaxis.setAutoRangeIncludesZero(true);
    yaxis.setLabel("Centrality/Attribute Value");
    chart.getXYPlot().setRangeAxis(yaxis);
    chart.setBackgroundPaint(Color.white);
    //chart.setPadding(new RectangleInsets(20,20,20,20));
    chart.getXYPlot().setBackgroundPaint(Color.white);
    chart.getXYPlot().setDomainGridlinePaint(Color.gray);
    chart.getXYPlot().setRangeGridlinePaint(Color.gray);
    return chart;
}