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);
}
}
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);
}
}
Aggregations