Search in sources :

Example 1 with BarChartComponent

use of org.olat.core.gui.components.chart.BarChartComponent in project OpenOLAT by OpenOLAT.

the class StatisticDisplayController method generateCharts.

private void generateCharts(Graph graph) {
    statisticVc_.contextPut("hasChart", Boolean.FALSE);
    statisticVc_.contextPut("hasChartError", Boolean.FALSE);
    if (graph == null || graph.numElements == 0) {
        Component ic = getInitialComponent();
        if (ic != null) {
            ic.setDirty(true);
        }
        return;
    }
    try {
        statisticVc_.contextPut("chartAlt", getTranslator().translate("chart.alt"));
        statisticVc_.contextPut("chartIntro", graph.chartIntroStr);
        statisticVc_.contextPut("hasChart", Boolean.TRUE);
        statisticVc_.contextPut("hasChartError", Boolean.FALSE);
        BarChartComponent chartCmp = new BarChartComponent("stats");
        List<String> labels = graph.getLabels();
        List<Integer> values = graph.getValues();
        BarSeries serie = new BarSeries();
        for (int i = 0; i < labels.size(); i++) {
            double value = values.get(i).doubleValue();
            String category = labels.get(i);
            serie.add(value, category);
        }
        chartCmp.addSeries(serie);
        statisticVc_.put("chart", chartCmp);
    } catch (RuntimeException re) {
        log_.warn("generateCharts: RuntimeException during chart generation: " + re, re);
    }
    Component ic = getInitialComponent();
    if (ic != null) {
        ic.setDirty(true);
    }
}
Also used : BarChartComponent(org.olat.core.gui.components.chart.BarChartComponent) BarSeries(org.olat.core.gui.components.chart.BarSeries) BarChartComponent(org.olat.core.gui.components.chart.BarChartComponent) Component(org.olat.core.gui.components.Component)

Example 2 with BarChartComponent

use of org.olat.core.gui.components.chart.BarChartComponent in project openolat by klemens.

the class StatisticDisplayController method generateCharts.

private void generateCharts(Graph graph) {
    statisticVc_.contextPut("hasChart", Boolean.FALSE);
    statisticVc_.contextPut("hasChartError", Boolean.FALSE);
    if (graph == null || graph.numElements == 0) {
        Component ic = getInitialComponent();
        if (ic != null) {
            ic.setDirty(true);
        }
        return;
    }
    try {
        statisticVc_.contextPut("chartAlt", getTranslator().translate("chart.alt"));
        statisticVc_.contextPut("chartIntro", graph.chartIntroStr);
        statisticVc_.contextPut("hasChart", Boolean.TRUE);
        statisticVc_.contextPut("hasChartError", Boolean.FALSE);
        BarChartComponent chartCmp = new BarChartComponent("stats");
        List<String> labels = graph.getLabels();
        List<Integer> values = graph.getValues();
        BarSeries serie = new BarSeries();
        for (int i = 0; i < labels.size(); i++) {
            double value = values.get(i).doubleValue();
            String category = labels.get(i);
            serie.add(value, category);
        }
        chartCmp.addSeries(serie);
        statisticVc_.put("chart", chartCmp);
    } catch (RuntimeException re) {
        log_.warn("generateCharts: RuntimeException during chart generation: " + re, re);
    }
    Component ic = getInitialComponent();
    if (ic != null) {
        ic.setDirty(true);
    }
}
Also used : BarChartComponent(org.olat.core.gui.components.chart.BarChartComponent) BarSeries(org.olat.core.gui.components.chart.BarSeries) BarChartComponent(org.olat.core.gui.components.chart.BarChartComponent) Component(org.olat.core.gui.components.Component)

Aggregations

Component (org.olat.core.gui.components.Component)2 BarChartComponent (org.olat.core.gui.components.chart.BarChartComponent)2 BarSeries (org.olat.core.gui.components.chart.BarSeries)2