Package com.ordobill.webapp.report

Source Code of com.ordobill.webapp.report.NormalDistribution

package com.ordobill.webapp.report;

import java.util.ArrayList;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.function.Function2D;
import org.jfree.data.function.NormalDistributionFunction2D;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.xy.XYDataset;
import com.ordobill.webapp.beans.Report;

public class NormalDistribution {

    public static double[][] createChart(Report reportBean) {
      System.out.println(reportBean.getSampleAve());
      System.out.println(reportBean.getStdDeviation());
        NormalDistributionFunction2D normaldistributionfunction2d = new NormalDistributionFunction2D(reportBean.getSampleAve(), reportBean.getStdDeviation());
        XYDataset dataset = DatasetUtilities.sampleFunction2D(normaldistributionfunction2d, reportBean.getSampleAve()-2.54*reportBean.getStdDeviation(), reportBean.getSampleAve()+2.54*reportBean.getStdDeviation(), 100, "Normal");
        int aa = dataset.getItemCount(0);
        double[][] data = new double[aa][2];
        for (int i=0;i<aa;i++) {
          data[i][0] = dataset.getX(0, i).doubleValue();
          data[i][1] = dataset.getY(0, i).doubleValue();
          //System.out.println(dataset.getY(0, i).doubleValue());
        }
        final JFreeChart chart = ChartFactory.createXYLineChart(
            "NormalDistribution",
            "X",
            "Y",
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false
        );

        //ChartFrame frame = new ChartFrame("NormalDistribution", chart);
        //frame.pack();
        //frame.setVisible(true);
      return data;
    }

}
TOP

Related Classes of com.ordobill.webapp.report.NormalDistribution

TOP
Copyright © 2018 www.massapi.com. 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.