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

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

Introduction

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

Prototype

public XYSeriesCollection() 

Source Link

Document

Constructs an empty dataset.

Usage

From source file:utils.Graficos_old.java

public static JFreeChart GraficoLinhas(List<CarCapContas> pagar, List<CarCapContas> receber, String titulo) {

    XYSeries series1 = new XYSeries("Pagar");

    //        CarCapContas contasPagar = new CarCapContas();
    for (CarCapContas contasPagar : pagar) {

        series1.add(contasPagar.getContaValorTotal(), contasPagar.getContaDataEmissao().getMonth());

    }// w  ww. j  a v a 2s.  co  m

    XYSeries series2 = new XYSeries("Receber");

    for (CarCapContas contasReceber : receber) {

        series2.add(contasReceber.getContaValorTotal(), contasReceber.getContaDataEmissao().getMonth());

    }

    XYSeriesCollection dataset = new XYSeriesCollection();

    dataset.addSeries(series1);
    dataset.addSeries(series2);

    JFreeChart chart = ChartFactory.createXYLineChart(titulo, // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

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

    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;

}

From source file:jesse.GA_ANN.DataVis.java

JFreeChart createChart()//Here Input MillSecond
{
    total = new XYSeries[10];
    XYSeriescollection = new XYSeriesCollection();
    for (int i = 0; i < 10; i++) {
        total[i] = new XYSeries(i);
        XYSeriescollection.addSeries(total[i]);
    }/*from  w  ww  .  java 2 s.  c o m*/

    dateaxis = new NumberAxis("Time");
    NumberAxis Conaxis = new NumberAxis("z??");
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1F, 0, 2));
    xylineandshaperenderer.setFillPaint(new Color(30, 30, 220), true);

    Conaxis.setRange(-1, 1);
    Conaxis.setAutoRange(true);
    Conaxis.setAutoRangeIncludesZero(false);

    XYPlot xyplot = new XYPlot(XYSeriescollection, dateaxis, Conaxis, xylineandshaperenderer);
    JFreeChart jfreechart = new JFreeChart("time-z", new Font("Arial", 1, 24), xyplot, true);
    ChartUtilities.applyCurrentTheme(jfreechart);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    return jfreechart;
}

From source file:app.Plot.java

public XYDataset createDataset(ArrayList<Integer> step, ArrayList<Double> frequency) {

    final XYSeriesCollection dataset = new XYSeriesCollection();
    final XYSeries c2 = new XYSeries("?2");
    for (int i = 0; i < 200; i++) {
        c2.add(step.get(i), frequency.get(i));
    }//w ww . j a  v a  2  s .com
    dataset.addSeries(c2);
    return dataset;
}

From source file:Transistor.JFETGraphViewer.java

/**
 * Creates new form JFETGraphViewer//w  w w . j a  va 2s  .c om
 * @param chart
 */
public JFETGraphViewer(JFreeChart chart) {
    super(chart);
    s = new XYSeries("JFET_Current(I_D)");
    data = new XYSeriesCollection();
    data.addSeries(s);
    info = TransistorInfo.getInstacne();
    this.makeNewSeries();

    initComponents();

    //this.chart = ChartFactory.createXYLineChart("Output characteristic V-I curves","V_ds","I_d",data,PlotOrientation.VERTICAL,true,true,false);        
    //pointer = new XYPointerAnnotation("This point",info.getVds(), getDrainCurrent(info.getVds()), PI/4.0);
    //XYPlot plot = (XYPlot)chart.getPlot();
    //plot.addAnnotation(pointer);                

}

From source file:jprobix.ui.SPlotFinal.java

private static XYDataset samplexydataset2() {
    int cols = 20;
    int rows = 20;
    double[][] values = new double[cols][rows];

    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    XYSeries series = new XYSeries("Random");

    Random rand = new Random();
    for (int i = 0; i < values.length; i++) {
        for (int j = 0; j < values.length; j++) {
            double x = Math.round(rand.nextDouble() * 500);
            double y = Math.round(rand.nextDouble() * 500);

            series.add(x, y);//from  w w w  . j  a  va2  s  .c o  m
        }
    }
    xySeriesCollection.addSeries(series);
    return xySeriesCollection;

}

From source file:RutherfordScattering.GraphViewPanel.java

public GraphViewPanel(JFreeChart chart) {
    super(chart);
    s = new XYSeries("Distance between alpha-nucleus");
    data = new XYSeriesCollection();
    data.addSeries(s);//from   w w w  .  j a  va 2s. co  m
    //this.chart = ChartFactory.createXYLineChart("Distance between","Time","Distance",data,PlotOrientation.VERTICAL,true,true,false);        
}

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);/*w  w  w.j av a2  s  .co m*/
    scoll.addSeries(serie2);
    JFreeChart chart = ChartFactory.createXYLineChart("LR decisions", "Nodes", "Left-Right decisions", scoll);
    this.setChart(chart);
    solver.plugMonitor(this);
}

From source file:au.edu.jcu.usb.USBPlotFrame.java

/**
 * Construct a Frame to plot our USB Data.
 *
 * The Frame contains an XY plot (scatter plot), with a single XYSeries.
 *
 * @throws HeadlessException /*w  w w.j a v a 2  s .  c o m*/
 */
public USBPlotFrame() throws HeadlessException {
    super("USB Plot");

    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    xySeries = new XYSeries("Value");

    xySeriesCollection.addSeries(xySeries);
    ChartPanel chartPanel = constructChart(xySeriesCollection);

    add(chartPanel, BorderLayout.CENTER);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
}

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);
    }/*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:org.jfree.chart.demo.AnnotationDemo2.java

private static XYDataset createDataset1() {
    XYSeries xyseries = new XYSeries("Random Data 1");
    xyseries.add(1.0D, 181.80000000000001D);
    xyseries.add(2D, 167.30000000000001D);
    xyseries.add(3D, 153.80000000000001D);
    xyseries.add(4D, 167.59999999999999D);
    xyseries.add(5D, 158.80000000000001D);
    xyseries.add(6D, 148.30000000000001D);
    xyseries.add(7D, 153.90000000000001D);
    xyseries.add(8D, 142.69999999999999D);
    xyseries.add(9D, 123.2D);//from w w w  .j  a v  a 2 s  .c o m
    xyseries.add(10D, 131.80000000000001D);
    xyseries.add(11D, 139.59999999999999D);
    xyseries.add(12D, 142.90000000000001D);
    xyseries.add(13D, 138.69999999999999D);
    xyseries.add(14D, 137.30000000000001D);
    xyseries.add(15D, 143.90000000000001D);
    xyseries.add(16D, 139.80000000000001D);
    xyseries.add(17D, 137D);
    xyseries.add(18D, 132.80000000000001D);
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    return xyseriescollection;
}