Package org.jfree.data.xy

Examples of org.jfree.data.xy.XYSeriesCollection


        XYSeries series1 = new XYSeries("Rotation");
        int numOfElements = r.getNumOfNodes();
        for(int i=0;i<numOfElements;i++){
                series1.add(-r.getDepth(i), r.getRotation(i));
            }
            XYSeriesCollection dataset = new XYSeriesCollection(series1);
            JFreeChart chart = ChartFactory.createXYLineChart("Rotation", "Depth (m)", "Rotation (rad)", dataset, PlotOrientation.HORIZONTAL, true, true, false);
            XYPlot plot = (XYPlot) chart.getPlot();
            plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
            XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
            renderer.setShapesVisible(true);
View Full Code Here


        XYSeries series1 = new XYSeries("Bending Moment");
        int numOfElements = r.getNumOfNodes();
        for(int i=0;i<numOfElements;i++){
                series1.add(-r.getDepth(i), r.getBendingMoment(i));
            }
            XYSeriesCollection dataset = new XYSeriesCollection(series1);
            JFreeChart chart = ChartFactory.createXYLineChart("Bending Moment", "Depth (m)", "Bending Moment (kNm)", dataset, PlotOrientation.HORIZONTAL, true, true, false);
            XYPlot plot = (XYPlot) chart.getPlot();
            plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
            XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
            renderer.setShapesVisible(true);
View Full Code Here

        XYSeries series1 = new XYSeries("Shear Force");
        int numOfElements = r.getNumOfNodes();
        for(int i=0;i<numOfElements;i++){
                series1.add(-r.getDepth(i), r.getShearForce(i));
            }
            XYSeriesCollection dataset = new XYSeriesCollection(series1);
            JFreeChart chart = ChartFactory.createXYLineChart("Shear Force", "Depth (m)", "Shear Force (kN)", dataset, PlotOrientation.HORIZONTAL, true, true, false);
            XYPlot plot = (XYPlot) chart.getPlot();
            plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
            XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
            renderer.setShapesVisible(true);
View Full Code Here

     */
    public static JFreeChart buildScatterPlot(final Number[] numbers, final String dataName, final boolean useLines, final boolean useLinearRegression) {
        if (numbers == null || numbers.length == 0) {
            return null;
        }
        XYSeriesCollection dataset = new XYSeriesCollection();

        XYSeries series = new XYSeries(dataName);
        for (int i = 0; i < numbers.length; i++) {
            series.add(i, numbers[i]);
        }
        dataset.addSeries(series);
        JFreeChart scatterPlot = buildScatterPlot(dataset,
                getMessage("ChartsUtils.report.scatter-plot.title"),
                getMessage("ChartsUtils.report.scatter-plot.xLabel"),
                dataName,
                useLines,
View Full Code Here

                    xMax = x;
                }
            }
        }
        // Create 2-point series for each of the original series
        XYSeriesCollection coll = new XYSeriesCollection();
        for (int i = 0; i < data.getSeriesCount(); i++) {
            XYSeries ser = data.getSeries(i);
            int n = ser.getItemCount();
            double sx = 0, sy = 0, sxx = 0, sxy = 0, syy = 0;
            for (int j = 0; j < n; j++) {
                double x = ser.getX(j).doubleValue();
                double y = ser.getY(j).doubleValue();
                sx += x;
                sy += y;
                sxx += x * x;
                sxy += x * y;
                syy += y * y;
            }
            double b = (n * sxy - sx * sy) / (n * sxx - sx * sx);
            double a = sy / n - b * sx / n;
            XYSeries regr = new XYSeries(ser.getKey());
            regr.add(xMin, a + b * xMin);
            regr.add(xMax, a + b * xMax);
            coll.addSeries(regr);
        }
        return coll;
    }
View Full Code Here

            }
        }
       
        // Chart generation.
        XYSeries[] series = new XYSeries[col.length];
        XYSeriesCollection dataset = new XYSeriesCollection();
       
        // Create dataset.
        for (int i = 0; i < col.length; i++) {
            if (firstRowHeading) {
                series[i] = new XYSeries(csvContent.get(0)[col[i]]);
            } else {
                series[i] = new XYSeries("Column " + col[i]);
            }
           
            for (int j = 0; j < csvContent.size(); j++) {
                if (!firstRowHeading || j > 0) {
                    try {
                        series[i].add(j, Double.parseDouble(csvContent.get(j)[col[i]]));
                    } catch (Exception e) {
                    }
                }
            }
           
            dataset.addSeries(series[i]);
        }
       
        JFreeChart chart = ChartFactory.createXYLineChart(
                "Content of " + csvFile.getName(), // chart title
                "", // x axis label
View Full Code Here

            String xAxisLabel,
            String yAxisLabel,
            String[] seriesNames,
            Double[][] seriesInt) {
        XYSeries[] series = new XYSeries[seriesInt.length];
        XYSeriesCollection dataset = new XYSeriesCollection();
        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
        renderer.setSeriesPaint(1, Color.black);
        renderer.setSeriesStroke(1, new BasicStroke(0.75f));
        renderer.setSeriesPaint(0, Color.red);
        renderer.setSeriesStroke(0, new BasicStroke(1.5f));

        for (int i = 0; i < seriesInt.length; i++) {
            series[i] = new XYSeries(seriesNames[i]);
           
            for (int j = 0; j < seriesInt[i].length; j++) {
                try {
                    series[i].add(j, seriesInt[i][j]);
                } catch (Exception e) {
                }
            }
           
            dataset.addSeries(series[i]);
        }

        NumberAxis domain = new NumberAxis(xAxisLabel);
        NumberAxis range = new NumberAxis(yAxisLabel);
        XYPlot plot = new XYPlot(dataset, domain, range, renderer);
View Full Code Here

        for (int i = 0; i < values.length; i++) {
            series.add(x, values[i]);
            x += step;
        }
       
        XYSeriesCollection serieses = new XYSeriesCollection(series);
        NumberAxis domain = new NumberAxis();
        NumberAxis range = new NumberAxis();

        if (width < SMALL_PIC || height < SMALL_PIC) {
            domain.setTickLabelsVisible(false);
View Full Code Here

        for (int i = 0; i < values.length; i++) {
            series.add(x, values[i]);
            x += step;
        }
       
        XYSeriesCollection serieses = new XYSeriesCollection(series);
        NumberAxis domain = new NumberAxis();
        NumberAxis range = new NumberAxis();

        if (width < SMALL_PIC || height < SMALL_PIC) {
            domain.setTickLabelsVisible(false);
View Full Code Here

  }

  private XYDataset createXYDataset(ChartValue[] values)
  {
    XYSeries series = null;
    XYSeriesCollection seriesCollection = new XYSeriesCollection();

    for (int i = 0; i < values.length; i++)
    {
      XYChartValue value = (XYChartValue) values[i];

      if (series == null || !series.getKey().equals(value.getSeries()))
      {
        if (series != null)
        {
          seriesCollection.addSeries(series);
        }

        series = new XYSeries(value.getSeries());
      }

      series.add(value.getValue(), value.getYValue());
    }

    if (series != null) seriesCollection.addSeries(series);

    return seriesCollection;
 
View Full Code Here

TOP

Related Classes of org.jfree.data.xy.XYSeriesCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.