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

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

Introduction

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

Prototype

public XYSeries(Comparable key) 

Source Link

Document

Creates a new empty series.

Usage

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

private static XYDataset createDataset() {
    XYSeries xyseries = new XYSeries("Random Data");
    xyseries.add(1.0D, 500.19999999999999D);
    xyseries.add(5D, 694.10000000000002D);
    xyseries.add(4D, 100D);/*  www.  ja  v a  2 s .  c om*/
    xyseries.add(12.5D, 734.39999999999998D);
    xyseries.add(17.300000000000001D, 453.19999999999999D);
    xyseries.add(21.199999999999999D, 500.19999999999999D);
    xyseries.add(21.899999999999999D, 9005.5D);
    xyseries.add(25.600000000000001D, 734.39999999999998D);
    xyseries.add(3000D, 453.19999999999999D);
    return new XYSeriesCollection(xyseries);
}

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

private static XYDataset createDataset() {
    XYSeries xyseries = new XYSeries("Series 1");
    xyseries.add(0.0D, 3D);//from w w  w  . ja  v a  2  s .co  m
    xyseries.add(1.0D, 3D);
    xyseries.add(2D, 0.0D);
    xyseries.add(3D, 1.0D);
    XYSeries xyseries1 = new XYSeries("Series 2");
    xyseries1.add(0.0D, 1.0D);
    xyseries1.add(1.0D, 2D);
    xyseries1.add(2D, 1.0D);
    xyseries1.add(3D, 3D);
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    xyseriescollection.addSeries(xyseries1);
    return xyseriescollection;
}

From source file:logica.LGraficapeso.java

public static void logicaBtnGraficar(JRadioButton jRLinea) {

    ChartPanel panel;//from ww  w . j  av  a2  s .co m
    JFreeChart chart = null;

    if (jRLinea.isSelected()) {
        // ejecuto linea

        XYSplineRenderer graficoLinea = new XYSplineRenderer();

        XYSeriesCollection dataset = new XYSeriesCollection();

        ValueAxis x = new NumberAxis();
        ValueAxis y = new NumberAxis();

        XYSeries serie = new XYSeries("Datos");

        XYPlot plot;

        graficoLinea.setSeriesPaint(0, Color.YELLOW);

        VGraficaPeso.getPanelLinea().removeAll();

        for (int i = 0; i < VGraficaPeso.getjTable1().getRowCount(); i++) {

            float valor1 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 0)));
            float valor2 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 1)));

            System.out.println("valores  " + valor1 + "   " + valor2);

            serie.add(valor1, valor2);

        }

        dataset.addSeries(serie);

        x.setLabel("MES");
        y.setLabel("peso");

        plot = new XYPlot(dataset, x, y, graficoLinea);

        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(10, 15);

        chart = new JFreeChart(plot);
        chart.setTitle("grafico");

        panel = new ChartPanel(chart);
        panel.setBounds(5, 10, 410, 350);

        VGraficaPeso.getPanelLinea().add(panel);
        VGraficaPeso.getPanelLinea().repaint();

    }

}

From source file:logica.LGraficaAltura.java

public static void logicaBtnGraficar(JRadioButton jRLinea) {

    ChartPanel panel;//from ww w. j ava  2  s . co  m
    JFreeChart chart = null;

    if (jRLinea.isSelected()) {
        // ejecuto linea

        XYSplineRenderer graficoLinea = new XYSplineRenderer();

        XYSeriesCollection dataset = new XYSeriesCollection();

        ValueAxis x = new NumberAxis();
        ValueAxis y = new NumberAxis();

        XYSeries serie = new XYSeries("Datos");

        XYPlot plot;

        graficoLinea.setSeriesPaint(0, Color.YELLOW);

        VGraficaAltura.getPanelLinea().removeAll();

        for (int i = 0; i < VGraficaAltura.getjTable1().getRowCount(); i++) {

            float valor1 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 0)));
            float valor2 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 1)));

            System.out.println("valores  " + valor1 + "   " + valor2);

            serie.add(valor1, valor2);

        }

        dataset.addSeries(serie);

        x.setLabel("MES");
        y.setLabel("ALTURA");

        plot = new XYPlot(dataset, x, y, graficoLinea);

        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(15, 30);

        chart = new JFreeChart(plot);
        chart.setTitle("grafico");

        panel = new ChartPanel(chart);
        panel.setBounds(5, 10, 410, 350);

        VGraficaAltura.getPanelLinea().add(panel);
        VGraficaAltura.getPanelLinea().repaint();

    }

}

From source file:MonteCarloWindowLogic.java

static void drawPointsOnChart(JPanel panelWhenInside, ArrayList<Point2D> convexHull, ArrayList<Point2D> hits,
        ArrayList<Point2D> miss) {
    panelWhenInside.removeAll();/*w ww .j  a  v a  2  s . c om*/
    panelWhenInside.setLayout(new java.awt.BorderLayout());

    XYSeries seriersHits = new XYSeries("Hits");
    convertArrayListToXYSeries(seriersHits, hits);

    XYSeries seriersMiss = new XYSeries("Miss");
    convertArrayListToXYSeries(seriersMiss, miss);
    //TODO refactor this, to handling hits, miss and than convex hull

    int pairsNumber = 0;
    if (convexHull != null)
        pairsNumber = convexHull.size() - 1;
    XYSeries covnexHullDivideOnPiars[] = new XYSeries[pairsNumber];

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        covnexHullDivideOnPiars[i] = new XYSeries("Convex hull pair " + i);
    }

    if (convexHull != null) {
        divideOnPairsAndConvertConvexHullIntoSeries(covnexHullDivideOnPiars, convexHull);
    }

    // Add the seriersAllPoints to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(seriersHits);
    dataset.addSeries(seriersMiss);

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        dataset.addSeries(covnexHullDivideOnPiars[i]);
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            null, // x-axis Label
            null, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            false, // Use tooltips
            false // Configure chart to generate URLs?
    );

    final XYPlot plot = chart.getXYPlot();
    ChartPanel chartPanel = new ChartPanel(chart);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.GREEN);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3));

    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShape(1, ShapeUtilities.createDiamond(3));

    for (int i = 2; i <= covnexHullDivideOnPiars.length + 1; i++) {
        renderer.setSeriesPaint(i, Color.black);
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesStroke(i, new BasicStroke(1.0f));
    }

    plot.setRenderer(renderer);

    panelWhenInside.add(chartPanel, BorderLayout.CENTER);
    panelWhenInside.validate();
}

From source file:LisajousApp.Draw.java

private static XYDataset createDataset() {

    XYSeries s1 = new XYSeries("");

    for (double t = 0; t <= 2 * Math.PI; t = t + 0.0005) {
        double x = Main.a * Math.sin(Main.n * t + Main.c);
        double y = Main.b * Math.sin(t);
        s1.add(x, y);/*from  w ww.  j  a  v  a 2  s.c  o  m*/
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(s1);
    return dataset;
}

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

private static XYDataset createDataset() {
    XYSeries xyseries = new XYSeries("Series 1");
    xyseries.add(1.0D, 3D);//from   w ww  .  jav  a  2s.c o  m
    xyseries.add(2D, 4D);
    xyseries.add(3D, 2D);
    xyseries.add(6D, 3D);
    XYSeries xyseries1 = new XYSeries("Series 2");
    xyseries1.add(1.0D, 7D);
    xyseries1.add(2D, 6D);
    xyseries1.add(3D, 9D);
    xyseries1.add(4D, 5D);
    xyseries1.add(6D, 4D);
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    xyseriescollection.addSeries(xyseries1);
    return xyseriescollection;
}

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 w  w . j av a  2s .c  om

    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:metodosnumericos.Graficador.java

public ChartPanel series(String f, double xi, double xs) {

    Evaluador func = new Evaluador();
    XYSeries series = new XYSeries("Funcion");

    double iter = xi;
    while (iter < xs) {
        double y = func.Evaluador2(f, iter);
        series.add(iter, y);//w w w  .j  a  va  2s .co  m
        System.out.println(iter + " " + y);
        iter = iter + 0.2;
    }
    XYSeriesCollection collection = new XYSeriesCollection(series);

    JFreeChart chart = ChartFactory.createXYLineChart("Grafica", "X", "Y", collection);

    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new java.awt.Dimension(400, 300));
    return panel;
}

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

private static XYDataset createDataset() {
    XYSeries xyseries = new XYSeries("Series 1");
    xyseries.add(-500D, -500D);//  ww w .  j a v a 2  s.  c om
    xyseries.add(-50D, -50D);
    xyseries.add(-5D, -5D);
    xyseries.add(0.0D, 0.0D);
    xyseries.add(5D, 5D);
    xyseries.add(50D, 50D);
    xyseries.add(500D, 500D);
    return new XYSeriesCollection(xyseries);
}