package app.GUI;

import app.DataUtil;
import app.PREPROCESSING.PrepConf;
import app.PREPROCESSING.Preprocesor;
import org.primefaces.model.chart.*;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Petr Flégl on 4.7.2016.
 */
@Named
@RequestScoped

public class Graf implements Serializable{


    private LineChartModel lineModel1;
    private LineChartModel lineModel2;
    private LineChartModel lineModel3;
    private LineChartModel lineModelvykonSv;
    private LineChartModel lineModelspotrebaA;
    private LineChartModel lineModelspotrebaV;
    private LineChartModel lineModelmetan;
    private LineChartModel lineModelsyra;
    private LineChartModel lineModelco2;
    private LineChartModel lineModeltan;
    private LineChartModel lineModelsulfatace;
    private LineChartModel lineModeloxidace;
    private LineChartModel lineModelzelezo;
    private LineChartModel lineModelspotrebaPlynu;
    private LineChartModel lineModelteplotaOleje;
    private LineChartModel lineModelmazaciTlak;


    @PostConstruct
    public void init() {
        createLineModels();
    }

    public LineChartModel getLineModel1() {
        return lineModel1;
    }
    public LineChartModel getLineModel2() {
        return lineModel2;
    }
    public LineChartModel getLineModel3() {
        return lineModel3;
    }
    public LineChartModel getLineModelVykonSv() {
        return lineModelvykonSv;
    }
    public LineChartModel getLineModelSpotrebaA() {
        return lineModelspotrebaA;
    }
    public LineChartModel getLineModelSpotrebaV() {
        return lineModelspotrebaV;
    }
    public LineChartModel getLineModelMetan() { return lineModelmetan; }
    public LineChartModel getLineModelSyra() {
        return lineModelsyra;
    }
    public LineChartModel getLineModelCO2() {
        return lineModelco2;
    }
    public LineChartModel getLineModelTan() {
        return lineModeltan;
    }
    public LineChartModel getLineModelSulfatace() {
        return lineModelsulfatace;
    }
    public LineChartModel getLineModelOxidace() {
        return lineModeloxidace;
    }
    public LineChartModel getLineModelZelezo() {
        return lineModelzelezo;
    }
    public LineChartModel getLineModelPlyn() {
        return lineModelspotrebaPlynu;
    }
    public LineChartModel getLineModelTeplotaOleje() {
        return lineModelteplotaOleje;
    }
    public LineChartModel getLineModelMazaciTlak() {
        return lineModelmazaciTlak;
    }


    //<--Model 1-->//
    private void createLineModels() {
        lineModel1 = initLinearModel();
        lineModel1.setTitle("Vývoj Biologie");
        lineModel1.setLegendPosition("e");
        Axis yAxis = lineModel1.getAxis(AxisType.Y);
        yAxis.setMin(0);
        yAxis.setMax(10);

        //Model 2//
        lineModel2 = initLinearModel();
        lineModel2.setTitle("Spotřeba pevných substrátů");
        lineModel2.setLegendPosition("e");

        yAxis = lineModel2.getAxis(AxisType.Y);
        yAxis.setMin(0);
        yAxis.setMax(11);

        //Model 3//
        lineModel3 = initLinearModel();
        lineModel3.setTitle("Stav olejové náplně");
        lineModel3.setLegendPosition("e");
        yAxis = lineModel3.getAxis(AxisType.Y);
        yAxis.setMin(0);
        yAxis.setMax(12);

        //Model 4//
        lineModelvykonSv = vykonSv();
        lineModelvykonSv.setTitle("Výkon generátoru svorky");
        lineModelvykonSv.setLegendPosition("e");
        lineModelvykonSv.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelvykonSv.getAxis(AxisType.Y);
        yAxis.setMin(12000);
        yAxis.setMax(15000);

        //Model 5//
        lineModelspotrebaA = spotrebaA();
        lineModelspotrebaA.setTitle("Spotřeba areálu");
        lineModelspotrebaA.setLegendPosition("e");
        lineModelspotrebaA.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelspotrebaA.getAxis(AxisType.Y);


        //Model 6//
        lineModelspotrebaV = spotrebaV();
        lineModelspotrebaV.setTitle("Vlastní spotřeba BPS");
        lineModelspotrebaV.setLegendPosition("e");
        lineModelspotrebaV.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelspotrebaV.getAxis(AxisType.Y);


        //Model 7//
        lineModelmetan = metan();
        lineModelmetan.setTitle("Metan");
        lineModelmetan.setLegendPosition("e");
        lineModelmetan.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelmetan.getAxis(AxisType.Y);
        yAxis.setMin(37);
        yAxis.setMax(58);


        //Model 8//
        lineModelsyra = syra();
        lineModelsyra.setTitle("Obsah sýry");
        lineModelsyra.setLegendPosition("e");
        lineModelsyra.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelsyra.getAxis(AxisType.Y);
        yAxis.setMin(0);
        yAxis.setMax(300);

        //Model 9//
        lineModelco2 = co2();
        lineModelco2.setTitle("CO2");
        lineModelco2.setLegendPosition("e");
        lineModelco2.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelco2.getAxis(AxisType.Y);
        yAxis.setMin(36);
        yAxis.setMax(54);

        //Model 10//
        lineModeltan = tan();
        lineModeltan.setTitle("TBN / AN");
        lineModeltan.setLegendPosition("e");
        lineModeltan.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModeltan.getAxis(AxisType.Y);


        //Model 11//
        lineModelsulfatace = sulfatace();
        lineModelsulfatace.setTitle("Sulfatace");
        lineModelsulfatace.setLegendPosition("e");
        lineModelsulfatace.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelsulfatace.getAxis(AxisType.Y);
        yAxis.setMin(-3);
        yAxis.setMax(33);

        //Model 12//
        lineModeloxidace = oxidace();
        lineModeloxidace.setTitle("Oxidace");
        lineModeloxidace.setLegendPosition("e");
        lineModeloxidace.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModeloxidace.getAxis(AxisType.Y);
        yAxis.setMin(3);
        yAxis.setMax(33);

        //Model 12,5//
        lineModelzelezo = zelezo();
        lineModelzelezo.setTitle("Obsah železa");
        lineModelzelezo.setLegendPosition("e");
        lineModelzelezo.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelzelezo.getAxis(AxisType.Y);
        yAxis.setMin(0);
        yAxis.setMax(9);

        //Model 13//
        lineModelspotrebaPlynu = plynS();
        lineModelspotrebaPlynu.setTitle("Spotreba plynu");
        lineModelspotrebaPlynu.setLegendPosition("e");
        lineModelspotrebaPlynu.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelspotrebaPlynu.getAxis(AxisType.Y);
        yAxis.setMin(5000);
        yAxis.setMax(7000);

        //Model 14//
        lineModelteplotaOleje = teplotaO();
        lineModelteplotaOleje.setTitle("Teplota oleje");
        lineModelteplotaOleje.setLegendPosition("e");
        lineModelteplotaOleje.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelteplotaOleje.getAxis(AxisType.Y);
        yAxis.setMin(90);
        yAxis.setMax(92);

        //Model 15//
        lineModelmazaciTlak = mazaciT();
        lineModelmazaciTlak.setTitle("Mazací tlak");
        lineModelmazaciTlak.setLegendPosition("e");
        lineModelmazaciTlak.getAxes().put(AxisType.X, new CategoryAxis(""));
        yAxis = lineModelmazaciTlak.getAxis(AxisType.Y);
        yAxis.setMin(4.25);
        yAxis.setMax(4.45);

    }

    private String months[] = {"Leden","Únor","Břez.","Duben","Květen","Červen","Červe.","Srpen","Září","Říjen","Listo.","Prosin."};
    private LineChartModel metan(){
        LineChartModel metan = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table5:metan", "podil metanu", "datumPlyn", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
        /*xxxx = */
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            metan.addSeries(s);
        }

        return metan;

    }


    private LineChartModel syra(){
        LineChartModel syra = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table5:syra", "podil syry", "datumPlyn", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
        /*xxxx = */
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            syra.addSeries(s);
        }

        return syra;

    }

    private LineChartModel co2(){
        LineChartModel co2 = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table5:cO2", "podil co2", "datumPlyn", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
        /*xxxx = */
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            co2.addSeries(s);
        }

        return co2;

    }

    private LineChartModel vykonSv(){
        LineChartModel vykonSv = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table10:vykon", "vykon na svorkach", "datum", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
        /*xxxx = */
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            vykonSv.addSeries(s);
        }

        return vykonSv;

    }
    private LineChartModel spotrebaA(){
        LineChartModel spotrebaA = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table10:areal", "spotreba arealu", "datum", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
        /*xxxx = */
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            spotrebaA.addSeries(s);
        }

        return spotrebaA;

    }

    private LineChartModel spotrebaV(){
        LineChartModel spotrebaV = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table10:vlsSpot", "spotreba vlastni", "datum", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
        /*xxxx = */
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            spotrebaV.addSeries(s);
        }

        return spotrebaV;

    }

    private LineChartModel plynS(){
        LineChartModel plynS = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table4:spotrebaPlynu", "spotreba plynu", "datumBio", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            plynS.addSeries(s);
        }

        return plynS;

    }

    private LineChartModel teplotaO(){
        LineChartModel teplotaO = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table7:teplotaOleje", "teplota oleje", "datumParam", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            teplotaO.addSeries(s);
        }

        return teplotaO;

    }

    private LineChartModel mazaciT(){
        LineChartModel mazaciT = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table7:mazaciTlak", "mazaci tlak", "datumParam", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            mazaciT.addSeries(s);
        }

        return mazaciT;

    }

    private LineChartModel sulfatace(){
        LineChartModel sulfatace = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table9:sulfatace", "Sulfatace", "datumRozboru", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            sulfatace.addSeries(s);
        }

        return sulfatace;

    }

    private LineChartModel oxidace(){
        LineChartModel oxidace = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table9:oxidace", "Oxidace", "datumRozboru", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            oxidace.addSeries(s);
        }

        return oxidace;

    }


    private LineChartModel zelezo(){
        LineChartModel zelezo = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<5;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table9:zelezo", "Zelezo", "datumRozboru", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data.setLabel(""+year);

                data.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            zelezo.addSeries(s);
        }

        return zelezo;

    }

    private LineChartModel tan(){
        LineChartModel tan = new LineChartModel();
        List<LineChartSeries> dataList = new ArrayList<>();

        List<PrepConf> monthData = new ArrayList<>();
        //0 => aktualni rok, 3=> pro 3 roky zpet tj -0, -1, -2
        for(int y=2;y<3;y++) {
            int year = DataUtil.getYear(y);
            //pro vsechny roky ZACATEK
            LineChartSeries data1 = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table9:tBN", "TBN", "datumRozboru", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data1.setLabel("TBN "+year);

                data1.set(months[m - 1], vals[0][0]);


            }
            LineChartSeries data2 = new LineChartSeries();

            for (int m = 1; m <= 12; m++) {

                monthData.add(new PrepConf("table9:aN", "AN", "datumRozboru", DataUtil.dateToTimestamp("1-" + m + "-"+year, "-"), DataUtil.dateToTimestamp("31-" + m + "-"+year, "-"), 0, 100, 0, 100));
                Preprocesor p = new Preprocesor(monthData);
                double vals[][] = p.getAverageData();
                monthData.clear();
                data2.setLabel("AN "+year);

                data2.set(months[m - 1], vals[0][0]);


            }
            dataList.add(data1);
            dataList.add(data2);
            //pro vsechny roky KONEC
        }
        for (LineChartSeries s: dataList) {
            tan.addSeries(s);
        }

        return tan;

    }




    private LineChartModel initLinearModel() {
        LineChartModel model = new LineChartModel();

        LineChartSeries series1 = new LineChartSeries();
        series1.setLabel("Series 1");

        series1.set(1, 2);
        series1.set(2, 1);
        series1.set(3, 3);
        series1.set(4, 6);
        series1.set(5, 8);

        LineChartSeries series2 = new LineChartSeries();
        series2.setLabel("Series 2");

        series2.set(1, 6);
        series2.set(2, 3);
        series2.set(3, 2);
        series2.set(4, 7);
        series2.set(5, 9);

        model.addSeries(series1);
        model.addSeries(series2);

        return model;
    }

}