        package app.GUI;
        import org.primefaces.model.chart.Axis;
        import org.primefaces.model.chart.AxisType;
        import org.primefaces.model.chart.BarChartModel;
        import org.primefaces.model.chart.ChartSeries;

        import javax.annotation.PostConstruct;
        import javax.faces.bean.ManagedBean;
        import java.io.Serializable;
/**
 * Created by Petr Flégl on 26.2.2017.
 */
@ManagedBean
public class ChartView implements Serializable{

    private BarChartModel barModel;

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

    public BarChartModel getBarModel() {
        return barModel;
    }


    private BarChartModel initBarModel() {
        BarChartModel model = new BarChartModel();

        ChartSeries stranaA = new ChartSeries();
        stranaA.setLabel("Strana A");
        stranaA.set("A1,B1", 370);
        stranaA.set("A2,B2", 384);
        stranaA.set("A3,B3", 396);
        stranaA.set("A4, B4", 400);
        stranaA.set("A5, B5", 376);
        stranaA.set("A6, B6", 385);

        ChartSeries stranaB = new ChartSeries();
        stranaB.setLabel("Strana B");
        stranaB.set("A1, B1", 406);
        stranaB.set("A2, B2", 400);
        stranaB.set("A3, B3", 388);
        stranaB.set("A4, B4", 372);
        stranaB.set("A5, B5", 380);
        stranaB.set("A6,B6", 390);

        model.addSeries(stranaA);
        model.addSeries(stranaB);

        return model;
    }


    private void createBarModel() {
        barModel = initBarModel();

        barModel.setTitle("Teploty válců");
        barModel.setLegendPosition("ne");

        Axis xAxis = barModel.getAxis(AxisType.X);
        xAxis.setLabel("Válec");

        Axis yAxis = barModel.getAxis(AxisType.Y);
        yAxis.setLabel("Teplota");
        yAxis.setMin(300);
        yAxis.setMax(450);
    }

}
