Commit 96298ec3 authored by michael.simon's avatar michael.simon
Browse files

fix service stats

parent 69422ac3
......@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.bean.sadm.user;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
......@@ -18,7 +19,9 @@ import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import org.primefaces.model.chart.PieChartModel;
import org.primefaces.model.charts.ChartData;
import org.primefaces.model.charts.pie.PieChartDataSet;
import org.primefaces.model.charts.pie.PieChartModel;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
......@@ -80,19 +83,39 @@ public class ServiceAdminStatsBean implements Serializable {
public PieChartModel getUserPerIdpPie() {
if (userPerIdpPie == null) {
userPerIdpPie = new PieChartModel();
ChartData data = new ChartData();
PieChartDataSet dataSet = new PieChartDataSet();
List<Number> values = new ArrayList<>();
List<String> labels = new ArrayList<>();
for (Object o : getUserPerIdpList()) {
List<Object> ol = (List<Object>) o;
SamlIdpMetadataEntity i = (SamlIdpMetadataEntity) ol.get(1);
userPerIdpPie.set(i.getOrgName(), (Number) ol.get(0));
values.add((Number) ol.get(0));
labels.add(i.getOrgName());
}
userPerIdpPie.setTitle(serviceEntity.getName() + " Registrations per IDP");
userPerIdpPie.setLegendPosition("e");
userPerIdpPie.setLegendRows(10);
userPerIdpPie.setLegendCols(1);
userPerIdpPie.setDiameter(300);
userPerIdpPie.setShowDataLabels(true);
List<String> bgColor = new ArrayList<>();
bgColor.add("#00876c");
bgColor.add("#439981");
bgColor.add("#6aaa96");
bgColor.add("#8cbcac");
bgColor.add("#aecdc2");
bgColor.add("#cfdfd9");
bgColor.add("#f1f1f1");
bgColor.add("#f1d4d4");
bgColor.add("#f0b8b8");
bgColor.add("#ec9c9d");
bgColor.add("#e67f83");
bgColor.add("#de6069");
bgColor.add("#d43d51");
dataSet.setBackgroundColor(bgColor);
dataSet.setData(values);
data.addChartDataSet(dataSet);
data.setLabels(labels);
userPerIdpPie.setData(data);
}
return userPerIdpPie;
}
......
......@@ -28,6 +28,7 @@
<!-- does not play well with new stylesheet -->
<!-- <p:chart type="pie" model="#{serviceAdminStatsBean.userPerIdpPie}" style="height:400px;" /> -->
<p:pieChart model="#{serviceAdminStatsBean.userPerIdpPie}" />
<p:dataTable id="dataTable" var="o" value="#{serviceAdminStatsBean.userPerIdpList}">
<p:column>
<f:facet name="header">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment