Example usage for org.jfree.data.xy XYSeriesCollection addSeries

List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection addSeries.

Prototype

public void addSeries(XYSeries series) 

Source Link

Document

Adds a series to the collection and sends a DatasetChangeEvent to all registered listeners.

Usage

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

/**
 * Creates a sample dataset./*www.j av  a 2  s .c  o m*/
 * 
 * @return A dataset.
 */
private XYDataset createSampleDataset() {
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 3.3);
    series1.add(2.0, 4.4);
    series1.add(3.0, 1.7);
    XYSeries series2 = new XYSeries("Series 2");
    series2.add(1.0, 7.3);
    series2.add(2.0, 6.8);
    series2.add(3.0, 9.6);
    series2.add(4.0, 5.6);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);
    return dataset;
}

From source file:utlis.HistogramPlot.java

public JFreeChart plotGrayChart(int[] histogram) {

    XYSeries xysBrightnes = new XYSeries("Brightnes");

    for (int i = 0; i < histogram.length; i++) {

        xysBrightnes.add(i, histogram[i]);
    }//w w w. ja  va2 s  . co  m

    XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(xysBrightnes);

    JFreeChart chart = ChartFactory.createXYLineChart("Histogram", "Color Value", "Pixel count", collection);
    try {
        ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300);
    } catch (IOException ex) {
        Logger.getLogger(HistogramPlot.class.getName()).log(Level.SEVERE, null, ex);
    }
    return chart;
}

From source file:com.mycompany.istudy.principalservices.GraphicalView.java

private XYDataset createDataset(Map<Double, Double> investedHoursPerWeek,
        Map<Double, Double> hoursToBeInvested) {
    final XYSeries moduleToWeek = new XYSeries("Actual Performance");

    investedHoursPerWeek.entrySet().stream().forEach((pair) -> {
        moduleToWeek.add((double) pair.getKey(), (double) pair.getValue());
    });//from  w ww . j a v  a  2 s . co m
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(moduleToWeek);

    final XYSeries optimalWorkload = new XYSeries("Optimal Performance ");

    hoursToBeInvested.entrySet().stream().forEach((pair) -> {
        optimalWorkload.add((double) pair.getKey(), (double) pair.getValue());
    });
    dataset.addSeries(optimalWorkload);
    return dataset;
}

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

/**
 * Creates a sample dataset.//  w  ww  .  j  av a  2 s  .c o m
 * 
 * @return A sample dataset.
 */
private IntervalXYDataset createDataset() {
    final XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 5.0);
    series.add(2.0, 7.8);
    series.add(3.0, 9.3);
    final XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(series);
    return new XYBarDataset(collection, 0.9);
}

From source file:playground.benjamin.scenarios.zurich.analysis.charts.BkDeltaUtilsQuantilesChart.java

private XYSeriesCollection createNeededDataset() {
    //instancing the dataset 
    XYSeriesCollection ds = new XYSeriesCollection();

    ds.addSeries(this.createSeries("delta utils over income quantiles",
            personalIncomeInQuantiles2Scores(populationInformation)));
    return ds;//from   w  w  w.  ja  v  a2s.co m
}

From source file:utlis.HistogramPlot.java

public JFreeChart plotColorChart(ArrayList<int[]> histograms) {

    XYSeries xysRed = new XYSeries("Red");
    XYSeries xysGreen = new XYSeries("Grean");
    XYSeries xysBlue = new XYSeries("blue");

    for (int i = 0; i < histograms.get(0).length; i++) {

        xysRed.add(i, histograms.get(0)[i]);
        xysBlue.add(i, histograms.get(2)[i]);
        xysGreen.add(i, histograms.get(1)[i]);
    }//from ww w.ja v  a2s. c  o  m

    XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(xysRed);
    collection.addSeries(xysBlue);
    collection.addSeries(xysGreen);

    JFreeChart chart = ChartFactory.createXYLineChart("Histogram", "Color Value", "Pixel count", collection);
    try {
        ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300);
    } catch (IOException ex) {
        Logger.getLogger(HistogramPlot.class.getName()).log(Level.SEVERE, null, ex);
    }
    return chart;
}

From source file:org.physionet.wfdb.examples.PlotECGQRSDemo2.java

public static XYDataset createDataset() {
    XYSeriesCollection result = new XYSeriesCollection();
    XYSeries ecgSignal = new XYSeries(1);
    XYSeries ecgAnnotation = new XYSeries(2);
    String recordName = "mitdb/100";
    int N = 5000;
    Double mxEcg = (double) 0;

    //Get ECG data from WFDB in number of samples
    Rdsamp rdsampexec = new Rdsamp();
    rdsampexec.setArgumentValue(Rdsamp.Arguments.stopTime, "s" + N);

    //Print time in second and values in high precision
    rdsampexec.setArgumentValue(Rdsamp.PrintTimeFormatLabel.P);
    rdsampexec.setArgumentValue(Rdsamp.Arguments.recordName, recordName);
    ArrayList[] results = rdsampexec.execTo2DString();

    //Insert data into plotting series 
    Double ecgSamp;/* ww w .  j av a 2 s . c o  m*/
    for (int n = 0; n < results[1].size(); n++) {
        ecgSamp = Double.valueOf((String) results[1].get(n));
        ecgSignal.add(n, ecgSamp);
        mxEcg = (mxEcg > ecgSamp) ? mxEcg : ecgSamp;
    }
    result.addSeries(ecgSignal);

    //Get the QRS annotations
    Wqrs wqrsExec = new Wqrs();
    wqrsExec.setArgumentValue(Wqrs.Arguments.recordName, recordName);
    wqrsExec.setArgumentValue(Wqrs.Arguments.stopTime, "s" + N);
    wqrsExec.execToString();

    //The annotation file will be stored at the current directory (./mitdb/100.wqrs)

    //Use RDANN to read the annotation file and store values in memory
    Rdann rdannExec = new Rdann();
    rdannExec.setArgumentValue(Rdann.Arguments.annotator, "wqrs");
    rdannExec.setArgumentValue(Rdann.Arguments.recordName, recordName);
    ArrayList<String> annotations = rdannExec.execToStringList();
    String[] tmpArr;
    for (String temp : annotations) {
        tmpArr = temp.split("\\s+");
        ecgAnnotation.add(Double.valueOf(tmpArr[2]), mxEcg);
    }

    result.addSeries(ecgAnnotation);
    return result;

}

From source file:FreeMemoryViewer.java

private XYDataset createDataset() {
    used = new XYSeries("Used");
    total = new XYSeries("Total");
    free = new XYSeries("Free");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(used);
    dataset.addSeries(total);/*from   w w  w  .  j a  va 2 s  .c om*/
    dataset.addSeries(free);
    return dataset;
}

From source file:org.chocosolver.gui.panels.LeftRightBranchPanel.java

public LeftRightBranchPanel(GUI frame) {
    super(frame);
    serie1 = new XYSeries("Left-Right decisions");
    serie2 = new XYSeries("Depth");
    XYSeriesCollection scoll = new XYSeriesCollection();
    scoll.addSeries(serie1);
    scoll.addSeries(serie2);/*w  w w. j  av a2s  .co  m*/
    JFreeChart chart = ChartFactory.createXYLineChart("LR decisions", "Nodes", "Left-Right decisions", scoll);
    this.setChart(chart);
    solver.plugMonitor(this);
}

From source file:it.alus.GPSreceiver.instruments.SatelliteRadar.java

public SatelliteRadar() {
    super(null);//from  w  w w  .  j a  v a 2  s .co m
    azimuth = new int[MAX_SAT];
    elevation = new int[MAX_SAT];
    snr = new int[MAX_SAT];
    resetArray();
    satSeries = new XYSeries("Satellites");
    XYSeriesCollection seriescollection = new XYSeriesCollection();
    seriescollection.addSeries(satSeries);
    jChart = ChartFactory.createPolarChart("Satellites", seriescollection, true, false, false);
    jChart.setBackgroundPaint(Color.white);
    PolarPlot polarplot = (PolarPlot) jChart.getPlot();
    polarplot.setBackgroundPaint(Color.lightGray);
    polarplot.setAngleGridlinePaint(Color.white);
    polarplot.setRadiusGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) polarplot.getAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    super.setChart(jChart);
    super.setMouseZoomable(false);
    super.setPreferredSize(new Dimension(500, 270));
}