Added country chart about organizations and services.
This commit is contained in:
parent
b479308383
commit
54b6275b9d
9 changed files with 224 additions and 2 deletions
|
@ -92,6 +92,21 @@ public class Organization extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the country code.
|
||||
*
|
||||
* @return the country code
|
||||
*/
|
||||
public String getCountryCode()
|
||||
{
|
||||
String result;
|
||||
|
||||
result = get("organization.country.code");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the crawled date.
|
||||
*
|
||||
|
|
|
@ -149,6 +149,21 @@ public class Service extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the country code.
|
||||
*
|
||||
* @return the country code
|
||||
*/
|
||||
public String getCountryCode()
|
||||
{
|
||||
String result;
|
||||
|
||||
result = get("organization.country.code");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
public LocalDateTime getCrawledDate()
|
||||
{
|
||||
LocalDateTime result;
|
||||
|
|
|
@ -41,7 +41,7 @@ import fr.devinsy.xidyn.data.TagDataManager;
|
|||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||
|
||||
/**
|
||||
* The Class SocialNetworksPage.
|
||||
* The Class FederationStatsPage.
|
||||
*/
|
||||
public class FederationStatsPage
|
||||
{
|
||||
|
@ -68,9 +68,12 @@ public class FederationStatsPage
|
|||
TagDataManager data = new TagDataManager();
|
||||
|
||||
data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations()));
|
||||
data.setContent("organizationCountryChart", Htmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations()));
|
||||
|
||||
data.setContent("hostServerTypeChart", Htmlizer.htmlizeHostServerTypeChart(federation.getAllServices()));
|
||||
data.setContent("hostProviderTypeChart", Htmlizer.htmlizeHostProviderTypeChart(federation.getAllServices()));
|
||||
data.setContent("serviceInstallTypeChart", Htmlizer.htmlizeServiceInstallTypeChart(federation.getAllServices()));
|
||||
data.setContent("serviceCountryChart", Htmlizer.htmlizeServiceCountryChart(federation.getAllServices()));
|
||||
|
||||
//
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ import fr.devinsy.statoolinfos.htmlize.charts.PieChart;
|
|||
import fr.devinsy.statoolinfos.htmlize.charts.PieChart.Position;
|
||||
import fr.devinsy.statoolinfos.htmlize.charts.PieChartView;
|
||||
import fr.devinsy.statoolinfos.stats.StatAgent;
|
||||
import fr.devinsy.statoolinfos.stats.country.CountryStats;
|
||||
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats;
|
||||
import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats;
|
||||
import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats;
|
||||
|
@ -247,6 +248,31 @@ public class Htmlizer
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param organizations
|
||||
* @return
|
||||
* @throws StatoolInfosException
|
||||
*/
|
||||
public static String htmlizeOrganizationCountryChart(final Organizations organizations) throws StatoolInfosException
|
||||
{
|
||||
String result;
|
||||
|
||||
CountryStats stats = StatAgent.statsCountry(organizations);
|
||||
|
||||
PieChart pie = new PieChart("Pays des membres");
|
||||
int index = 0;
|
||||
for (String country : stats.keySet())
|
||||
{
|
||||
pie.add(country, stats.get(country), ChartColor.values()[index]);
|
||||
}
|
||||
pie.setLegendPosition(Position.RIGHT);
|
||||
|
||||
result = PieChartView.build(pie);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Htmlize organization turnout chart.
|
||||
*
|
||||
|
@ -296,6 +322,35 @@ public class Htmlizer
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Htmlize service country chart.
|
||||
*
|
||||
* @param services
|
||||
* the services
|
||||
* @return the string
|
||||
* @throws StatoolInfosException
|
||||
* the statool infos exception
|
||||
*/
|
||||
public static String htmlizeServiceCountryChart(final Services services) throws StatoolInfosException
|
||||
{
|
||||
String result;
|
||||
|
||||
CountryStats stats = StatAgent.statsCountry(services);
|
||||
|
||||
PieChart pie = new PieChart("Pays des services");
|
||||
int index = 0;
|
||||
for (String country : stats.keySet())
|
||||
{
|
||||
pie.add(country, stats.get(country), ChartColor.values()[index]);
|
||||
}
|
||||
pie.setLegendPosition(Position.RIGHT);
|
||||
|
||||
result = PieChartView.build(pie);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Htmlize service install type chart.
|
||||
*
|
||||
|
|
|
@ -89,6 +89,7 @@ public class OrganizationStatsPage
|
|||
data.setContent("hostServerTypeChart", Htmlizer.htmlizeHostServerTypeChart(organization.getServices()));
|
||||
data.setContent("hostProviderTypeChart", Htmlizer.htmlizeHostProviderTypeChart(organization.getServices()));
|
||||
data.setContent("serviceInstallTypeChart", Htmlizer.htmlizeServiceInstallTypeChart(organization.getServices()));
|
||||
data.setContent("serviceCountryChart", Htmlizer.htmlizeServiceCountryChart(organization.getServices()));
|
||||
|
||||
//
|
||||
{
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
<div>
|
||||
<div>
|
||||
<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>
|
||||
<div>
|
||||
<div id="hostServerTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
<div id="hostProviderTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
<div id="serviceInstallTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
<div id="serviceCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div id="registrationTypeChart" class="column chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<div id="hostServerTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
<div id="hostProviderTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
<div id="serviceInstallTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
<div id="serviceCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div id="registrationTypeChart" class="column chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -40,6 +40,7 @@ import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
|||
import fr.devinsy.statoolinfos.properties.PathPropertyList;
|
||||
import fr.devinsy.statoolinfos.stats.categories.CategoryStat;
|
||||
import fr.devinsy.statoolinfos.stats.categories.CategoryStats;
|
||||
import fr.devinsy.statoolinfos.stats.country.CountryStats;
|
||||
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats;
|
||||
import fr.devinsy.statoolinfos.stats.properties.PropertyStats;
|
||||
import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStats;
|
||||
|
@ -330,6 +331,52 @@ public class StatAgent
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stats country.
|
||||
*
|
||||
* @param organizations
|
||||
* the organizations
|
||||
* @return the country stats
|
||||
*/
|
||||
public static CountryStats statsCountry(final Organizations organizations)
|
||||
{
|
||||
CountryStats result;
|
||||
|
||||
result = new CountryStats();
|
||||
|
||||
//
|
||||
for (Organization organization : organizations)
|
||||
{
|
||||
result.inc(organization.getCountryCode());
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stats country.
|
||||
*
|
||||
* @param services
|
||||
* the services
|
||||
* @return the country stats
|
||||
*/
|
||||
public static CountryStats statsCountry(final Services services)
|
||||
{
|
||||
CountryStats result;
|
||||
|
||||
result = new CountryStats();
|
||||
|
||||
//
|
||||
for (Service service : services)
|
||||
{
|
||||
result.inc(service.getCountryCode());
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat service install type.
|
||||
*
|
||||
|
|
83
src/fr/devinsy/statoolinfos/stats/country/CountryStats.java
Normal file
83
src/fr/devinsy/statoolinfos/stats/country/CountryStats.java
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
* StatoolInfos is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* StatoolInfos is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.devinsy.statoolinfos.stats.country;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* The Class CountryStats.
|
||||
*/
|
||||
public class CountryStats extends HashMap<String, Integer>
|
||||
{
|
||||
private static final long serialVersionUID = -8177123413128556290L;
|
||||
|
||||
/**
|
||||
* Instantiates a new country stats.
|
||||
*/
|
||||
public CountryStats()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total count.
|
||||
*
|
||||
* @return the total count
|
||||
*/
|
||||
public long getTotalCount()
|
||||
{
|
||||
long result;
|
||||
|
||||
result = 0;
|
||||
for (long value : this.values())
|
||||
{
|
||||
result += value;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inc.
|
||||
*
|
||||
* @param country
|
||||
* the country
|
||||
*/
|
||||
public void inc(final String country)
|
||||
{
|
||||
if (StringUtils.isBlank(country))
|
||||
{
|
||||
inc("Inconnu");
|
||||
}
|
||||
else
|
||||
{
|
||||
Integer currentValue = get(country);
|
||||
if (currentValue == null)
|
||||
{
|
||||
currentValue = 0;
|
||||
}
|
||||
|
||||
currentValue += 1;
|
||||
put(country, currentValue);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue