Added member count chart in federation stats.

This commit is contained in:
Christian P. MOMON 2021-01-15 18:00:29 +01:00
parent 95a1d64f37
commit 3c095c47fe
3 changed files with 35 additions and 0 deletions

View file

@ -69,6 +69,7 @@ public class FederationStatsPage
data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations())); data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations()));
data.setContent("organizationCountryChart", Htmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations())); data.setContent("organizationCountryChart", Htmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations()));
data.setContent("organizationCountChart", Htmlizer.htmlizeOrganizationCountChart(federation));
data.setContent("hostServerTypeChart", Htmlizer.htmlizeHostServerTypeChart(federation.getAllServices())); data.setContent("hostServerTypeChart", Htmlizer.htmlizeHostServerTypeChart(federation.getAllServices()));
data.setContent("hostProviderTypeChart", Htmlizer.htmlizeHostProviderTypeChart(federation.getAllServices())); data.setContent("hostProviderTypeChart", Htmlizer.htmlizeHostProviderTypeChart(federation.getAllServices()));

View file

@ -29,17 +29,20 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext; import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Category; import fr.devinsy.statoolinfos.core.Category;
import fr.devinsy.statoolinfos.core.Configuration; import fr.devinsy.statoolinfos.core.Configuration;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Organizations; import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils; import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.htmlize.charts.BarChart; import fr.devinsy.statoolinfos.htmlize.charts.BarChart;
import fr.devinsy.statoolinfos.htmlize.charts.BarChartView;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.htmlize.charts.DoughnutChartView; import fr.devinsy.statoolinfos.htmlize.charts.DoughnutChartView;
import fr.devinsy.statoolinfos.htmlize.charts.PieChart; import fr.devinsy.statoolinfos.htmlize.charts.PieChart;
import fr.devinsy.statoolinfos.htmlize.charts.PieChart.Position; import fr.devinsy.statoolinfos.htmlize.charts.PieChart.Position;
import fr.devinsy.statoolinfos.htmlize.charts.PieChartView; import fr.devinsy.statoolinfos.htmlize.charts.PieChartView;
import fr.devinsy.statoolinfos.properties.PathProperty;
import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.country.CountryStats; import fr.devinsy.statoolinfos.stats.country.CountryStats;
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats; import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats;
@ -248,6 +251,36 @@ public class Htmlizer
return result; return result;
} }
/**
* Htmlize organization count chart.
*
* @param federation
* the federation
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlizeOrganizationCountChart(final Federation federation) throws StatoolInfosException
{
String result;
BarChart chart;
chart = new BarChart("Nombre de membres");
for (PathProperty property : federation.getByPrefix("metrics.federation.members.count"))
{
if (property.getLeaf().matches("\\d\\d\\d\\d"))
{
chart.add(property.getLeaf(), Double.parseDouble(property.getValue()), ChartColor.GREEN);
}
}
result = BarChartView.build(chart);
//
return result;
}
/** /**
* @param organizations * @param organizations
* @return * @return

View file

@ -18,6 +18,7 @@
<div> <div>
<div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/> <div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="organizationCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/> <div id="organizationCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="organizationCountChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div> </div>
<div> <div>
<div id="hostServerTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/> <div id="hostServerTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>