diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java
index 1513fca..75f4ea1 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java
@@ -29,11 +29,6 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
-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.DoughnutChartView;
-import fr.devinsy.statoolinfos.htmlize.charts.PieChart;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
import fr.devinsy.xidyn.XidynException;
@@ -67,57 +62,36 @@ public class FederationStatsPage
TagDataManager data = new TagDataManager();
- data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations()));
- data.setContent("organizationCountryChart", Htmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations()));
- data.setContent("organizationCountChart", Htmlizer.htmlizeOrganizationCountChart(federation));
- data.setContent("organizationInOutChart", Htmlizer.htmlizeOrganizationInOutChart(federation));
+ data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations()));
+ data.setContent("organizationCountryChart", ChartHtmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations()));
+ data.setContent("organizationCountChart", ChartHtmlizer.htmlizeOrganizationCountChart(federation));
+ data.setContent("organizationInOutChart", ChartHtmlizer.htmlizeOrganizationInOutChart(federation));
- 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()));
+ data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(federation.getAllServices()));
+ data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(federation.getAllServices()));
+ data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(federation.getAllServices()));
+ data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(federation.getAllServices()));
//
{
RegistrationStats stats = StatAgent.statRegistrationTypes(federation.getAllServices());
- BarChart bar = Htmlizer.toBarChart(stats);
- data.setContent("registrationTypeChart", BarChartView.build(bar));
-
- PieChart pie = new PieChart("Sans");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getNoneCount(), ChartColor.GREEN);
- pie.add("Autre", stats.getCount() - stats.getNoneCount(), ChartColor.BLUE);
- data.setContent("registrationNoneTypeChart", DoughnutChartView.build(pie));
-
- pie = new PieChart("Libre");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getFreeCount(), ChartColor.YELLOW);
- pie.add("Libre", stats.getCount() - stats.getFreeCount(), ChartColor.BLUE);
- data.setContent("registrationFreeTypeChart", DoughnutChartView.build(pie));
-
- pie = new PieChart("Membre");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getMemberCount(), ChartColor.ORANGE);
- pie.add("Membre", stats.getCount() - stats.getMemberCount(), ChartColor.BLUE);
- data.setContent("registrationMemberTypeChart", DoughnutChartView.build(pie));
-
- pie = new PieChart("Client");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getClientCount(), ChartColor.RED);
- pie.add("Client", stats.getCount() - stats.getClientCount(), ChartColor.BLUE);
- data.setContent("registrationClientTypeChart", DoughnutChartView.build(pie));
+ data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats));
+ data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats));
+ data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats));
+ data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats));
+ data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats));
}
- data.setContent("serviceCountYearChart", Htmlizer.htmlizeServiceCountYearChart(federation));
- data.setContent("serviceDateStatusChart", Htmlizer.htmlizeServiceDateStatusChart(federation.getAllServices()));
+ data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(federation));
+ data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(federation.getAllServices()));
- data.setContent("softwareDistributionChart", Htmlizer.htmlizeSoftwareDistributionChart());
- data.setContent("softwareDistributionPieChart", Htmlizer.htmlizeSoftwareDistributionPieChart(federation.getAllServices()));
- data.setContent("categoryDistributionChart", Htmlizer.htmlizeCategoryDistributionChart());
- data.setContent("categoryDistributionPieChart", Htmlizer.htmlizeCatergoryDistributionPieChart(federation.getAllServices()));
+ data.setContent("softwareDistributionChart", ChartHtmlizer.htmlizeSoftwareDistributionChart());
+ data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(federation.getAllServices()));
+ data.setContent("categoryDistributionChart", ChartHtmlizer.htmlizeCategoryDistributionChart());
+ data.setContent("categoryDistributionPieChart", ChartHtmlizer.htmlizeCatergoryDistributionPieChart(federation.getAllServices()));
- data.setContent("hostNameChart", Htmlizer.htmlizeHostNamePieChart(federation.getAllServices()));
+ data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(federation.getAllServices()));
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml", data).toString();
diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
index f45ad4b..dade0e0 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
@@ -20,8 +20,6 @@ package fr.devinsy.statoolinfos.htmlize;
import java.io.File;
import java.io.IOException;
-import java.time.LocalDate;
-import java.time.YearMonth;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
@@ -29,42 +27,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
-import fr.devinsy.statoolinfos.core.Categories;
import fr.devinsy.statoolinfos.core.Category;
import fr.devinsy.statoolinfos.core.Configuration;
-import fr.devinsy.statoolinfos.core.Federation;
-import fr.devinsy.statoolinfos.core.Organization;
-import fr.devinsy.statoolinfos.core.Organizations;
-import fr.devinsy.statoolinfos.core.Service;
-import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
-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.ChartColors;
-import fr.devinsy.statoolinfos.htmlize.charts.DoughnutChartView;
-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.metrics.StringCounter;
-import fr.devinsy.statoolinfos.metrics.StringCounterList;
-import fr.devinsy.statoolinfos.metrics.StringCounters;
-import fr.devinsy.statoolinfos.properties.PathProperty;
-import fr.devinsy.statoolinfos.properties.PathPropertyList;
-import fr.devinsy.statoolinfos.stats.StatAgent;
-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.services.HostProviderTypeStats;
-import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats;
-import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
-import fr.devinsy.statoolinfos.stats.services.ServiceInstallTypeStats;
-import fr.devinsy.statoolinfos.stats.softwares.SoftwareStat;
-import fr.devinsy.statoolinfos.stats.softwares.SoftwareStats;
import fr.devinsy.statoolinfos.util.URLUtils;
-import fr.devinsy.strings.StringList;
/**
* The Class Htmlizer.
@@ -209,881 +176,4 @@ public class Htmlizer
SoftwarePage.buildAll();
SocialNetworksPage.buildAll();
}
-
- /**
- * Htmlize category distribution chart.
- *
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeCategoryDistributionChart() throws StatoolInfosException
- {
- String result;
-
- BarChart chart;
-
- chart = new BarChart("Distribution des catégories les plus proposées");
- chart.addDataset("Catégories");
-
- Federation federation = HtmlizerContext.instance().getFederation();
- Categories categories = HtmlizerContext.instance().getCategories();
-
- CategoryStats stats = StatAgent.statAllCategories(federation, categories);
- stats.sortByServiceCount().reverse();
-
- for (CategoryStat stat : stats)
- {
- if (stat.getServiceCount() > 0)
- {
- chart.add(stat.getCategory().getName(), stat.getServiceCount(), ChartColor.PURPLE);
- }
- }
-
- result = BarChartView.build(chart);
-
- //
- return result;
- }
-
- /**
- * Htmlize catergory distribution pie chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeCatergoryDistributionPieChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- Federation federation = HtmlizerContext.instance().getFederation();
- Categories categories = HtmlizerContext.instance().getCategories();
-
- CategoryStats stats = StatAgent.statAllCategories(federation, categories);
- stats.sortByServiceCount().reverse();
-
- ChartColors colors = ChartColor.valueList();
- colors.remove(ChartColor.BLUE);
-
- PieChart pie = new PieChart("Répartition des services par catégorie");
- int index = 0;
- while ((index < stats.size() && (index < 10)))
- {
- ChartColor color = colors.get(index);
- CategoryStat stat = stats.get(index);
- pie.add(StringUtils.abbreviate(stat.getCategory().getName(), 30), stat.getServiceCount(), color);
-
- index += 1;
- }
-
- int others = 0;
- while (index < stats.size())
- {
- CategoryStat stat = stats.get(index);
- others += stat.getServiceCount();
-
- index += 1;
- }
- pie.add("Autres catégories", others, ChartColor.BLUE);
- pie.setLegendPosition(Position.RIGHT);
-
- result = DoughnutChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * Htmlize host name pie chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeHostNamePieChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- ChartColors colors = ChartColor.valueList();
- colors.remove(ChartColor.BLUE);
-
- StringCounters counters = new StringCounters();
- long unknowns = 0;
- for (Service service : services)
- {
- if (service.getHostProviderType() == null)
- {
- unknowns += 1;
- }
- else
- {
- switch (service.getHostProviderType())
- {
- case HOME:
- counters.inc("Auto-hébergé");
- break;
-
- case HOSTEDBAY:
- case HOSTEDSERVER:
- case OUTSOURCED:
- counters.inc(service.getHostName());
- break;
-
- case UNKNOWN:
- unknowns += 1;
- default:
- }
- }
- }
-
- StringCounterList list = counters.toList().sortByCounter().reverse();
-
- PieChart pie = new PieChart("Hébergeurs des services");
- pie.setLegendPosition(Position.RIGHT);
-
- int index = 0;
- while ((index < list.size() && (index < 9)))
- {
- ChartColor color = colors.get(index);
- StringCounter counter = list.get(index);
- pie.add(counter.getString(), counter.getCounter(), color);
-
- index += 1;
- }
-
- int others = 0;
- while (index < list.size())
- {
- StringCounter counter = list.get(index);
- others += counter.getCounter();
-
- index += 1;
- }
- pie.add("Autres", others, ChartColor.GREY);
- pie.add("Inconnus", unknowns, ChartColor.BLUE);
-
- result = DoughnutChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * Htmlize host provider type chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- */
- public static String htmlizeHostProviderTypeChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- HostProviderTypeStats stats = StatAgent.statHostProviderType(services);
-
- PieChart pie = new PieChart("Types d'hébergement");
- pie.add("Home", stats.getHomeCount(), ChartColor.GREEN);
- pie.add("Baie", stats.getHostedBayCount(), ChartColor.YELLOW);
- pie.add("Serveur", stats.getHostedServerCount(), ChartColor.ORANGE);
- pie.add("Externalisé", stats.getOutsourcedCount(), ChartColor.RED);
- pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE);
- pie.setLegendPosition(Position.RIGHT);
-
- result = DoughnutChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * Htmlize host server type chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- */
- public static String htmlizeHostServerTypeChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- HostServerTypeStats stats = StatAgent.statHostServerType(services);
-
- PieChart pie = new PieChart("Types de serveur");
- pie.add("Nano", stats.getNanoCount(), ChartColor.PURPLE);
- pie.add("Physique", stats.getPhysicalCount(), ChartColor.GREEN);
- pie.add("Virtuel", stats.getVirtualCount(), ChartColor.YELLOW);
- pie.add("Mutualisé", stats.getSharedCount(), ChartColor.ORANGE);
- pie.add("Cloud", stats.getCloudCount(), ChartColor.RED);
- pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE);
- pie.setLegendPosition(Position.RIGHT);
-
- result = DoughnutChartView.build(pie);
-
- //
- 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");
- chart.addDataset("Membres");
-
- PathPropertyList values = federation.getByYearPrefix("metrics.members.count").sortByPath();
-
- for (PathProperty property : values)
- {
- chart.add(property.getLeaf(), Double.parseDouble(property.getValue()), ChartColor.GREEN);
- }
-
- result = BarChartView.build(chart);
-
- //
- 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");
-
- StringList countries = new StringList(stats.keySet()).sort();
- countries.remove(CountryStats.UNKNOWN_LABEL);
-
- ChartColors colors = new ChartColors();
- colors.add(ChartColor.GREEN);
- colors.add(ChartColor.ORANGE);
- colors.add(ChartColor.RED);
- colors.add(ChartColor.PURPLE);
- colors.add(ChartColor.TURQUOISE);
- colors.add(ChartColor.YELLOW);
-
- int index = 0;
- for (String country : countries)
- {
- pie.add(country, stats.get(country), colors.get(index));
-
- index += 1;
- }
- pie.add("Inconnu", stats.getUnknown(), ChartColor.BLUE);
-
- pie.setLegendPosition(Position.RIGHT);
-
- result = PieChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * Htmlize organization in out chart.
- *
- * @param federation
- * the federation
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeOrganizationInOutChart(final Federation federation) throws StatoolInfosException
- {
- String result;
-
- BarChart chart = new BarChart("Entrées/Sorties");
- // chart.setStacked(true);
-
- chart.addDataset("Entrées");
- PathPropertyList values = federation.getByYearPrefix("metrics.members.in").sortByPath();
- for (PathProperty property : values)
- {
- chart.getLabels().add(property.getLeaf());
- chart.add(0, Double.parseDouble(property.getValue()), ChartColor.GREEN);
- }
-
- chart.addDataset("Sorties");
- values = federation.getByYearPrefix("metrics.members.out").sortByPath();
- for (PathProperty property : values)
- {
- chart.add(1, Double.parseDouble(property.getValue()), ChartColor.RED);
- }
-
- result = BarChartView.build(chart);
-
- //
- return result;
- }
-
- /**
- * Htmlize organization turnout chart.
- *
- * @param organization
- * the organization
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeOrganizationTurnoutChart(final Organization organization) throws StatoolInfosException
- {
- String result;
-
- Organizations organizations = new Organizations();
- organizations.add(organization);
-
- result = htmlizeOrganizationTurnoutChart(organizations);
-
- //
- return result;
- }
-
- /**
- * Htmlize organization turnout chart.
- *
- * @param organizations
- * the organizations
- * @return the string
- * @throws StatoolInfosException
- */
- public static String htmlizeOrganizationTurnoutChart(final Organizations organizations) throws StatoolInfosException
- {
- String result;
-
- OrganizationTurnoutStats stats = StatAgent.statsOrganizationTurnout(organizations);
-
- PieChart pie = new PieChart("Participation");
- pie.add("1 fichier", stats.getWithSelfFileCount(), ChartColor.ORANGE);
- pie.add("n fichiers", stats.getWithServiceFileCount(), ChartColor.YELLOW);
- pie.add("Métriques", stats.getWithServiceMetricCount(), ChartColor.GREEN);
- pie.add("Passive", stats.getPassiveCount(), ChartColor.BLUE);
- pie.setLegendPosition(Position.RIGHT);
-
- result = PieChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * Htmlize service count month chart.
- *
- * @param federation
- * the federation
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceCountMonthChart(final Federation federation) throws StatoolInfosException
- {
- String result;
-
- result = htmlizeServiceCountMonthChart(federation.getAllServices(),
- YearMonth.from(StatoolInfosUtils.parseDate(federation.getStartDate())));
-
- //
- return result;
- }
-
- /**
- * Htmlize service count chart.
- *
- * @param organization
- * the organization
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceCountMonthChart(final Organization organization) throws StatoolInfosException
- {
- String result;
-
- LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate());
-
- if (startDate == null)
- {
- result = null;
- }
- else
- {
- result = htmlizeServiceCountMonthChart(organization.getServices(), YearMonth.from(startDate));
- }
-
- //
- return result;
- }
-
- /**
- * Htmlize service count chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceCountMonthChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- YearMonth first = null;
- for (Service service : services)
- {
- LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate());
- if (date != null)
- {
- YearMonth current = YearMonth.from(date);
- if ((first == null) || (first.isBefore(current)))
- {
- first = current;
- }
- }
- }
-
- result = htmlizeServiceCountMonthChart(services, first);
-
- //
- return result;
- }
-
- /**
- * Htmlize service count month chart.
- *
- * @param services
- * the services
- * @param first
- * the first
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceCountMonthChart(final Services services, final YearMonth first) throws StatoolInfosException
- {
- String result;
-
- BarChart chart;
-
- chart = new BarChart("Nombre de services (mois)");
- chart.addDataset("Services");
-
- YearMonth now = YearMonth.now();
- YearMonth current = first;
- while (current.compareTo(now) <= 0)
- {
- long count = 0;
- for (Service service : services)
- {
- LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate());
- LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate());
-
- if (startDate != null)
- {
- YearMonth start = YearMonth.from(startDate);
- YearMonth end;
- if (endDate == null)
- {
- end = now;
- }
- else
- {
- end = YearMonth.from(endDate);
- }
-
- if ((current.compareTo(start) >= 0) && (current.compareTo(end) <= 0))
- {
- count += 1;
- }
- }
- }
-
- chart.add(current.toString(), count, ChartColor.VIOLET);
-
- current = current.plusMonths(1);
- }
-
- result = BarChartView.build(chart);
-
- //
- 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");
- StringList countries = new StringList(stats.keySet()).sort();
- countries.remove(CountryStats.UNKNOWN_LABEL);
-
- ChartColors colors = new ChartColors();
- colors.add(ChartColor.GREEN);
- colors.add(ChartColor.ORANGE);
- colors.add(ChartColor.RED);
- colors.add(ChartColor.PURPLE);
- colors.add(ChartColor.TURQUOISE);
- colors.add(ChartColor.YELLOW);
-
- int index = 0;
- for (String country : countries)
- {
- pie.add(country, stats.get(country), colors.get(index));
-
- index += 1;
- }
- pie.add("Inconnu", stats.getUnknown(), ChartColor.BLUE);
-
- pie.setLegendPosition(Position.RIGHT);
-
- result = PieChartView.build(pie);
-
- //
- return result;
- }
-
- public static String htmlizeServiceCountYearChart(final Federation federation) throws StatoolInfosException
- {
- String result;
-
- result = htmlizeServiceCountYearChart(federation.getAllServices(),
- StatoolInfosUtils.parseDate(federation.getStartDate()).getYear());
-
- //
- return result;
- }
-
- /**
- * Htmlize service count year chart.
- *
- * @param organization
- * the organization
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceCountYearChart(final Organization organization) throws StatoolInfosException
- {
- String result;
-
- LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate());
-
- if (startDate == null)
- {
- result = null;
- }
- else
- {
- result = htmlizeServiceCountYearChart(organization.getServices(), startDate.getYear());
- }
-
- //
- return result;
- }
-
- /**
- * Htmlize service count year chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceCountYearChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- Integer first = null;
- for (Service service : services)
- {
- LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate());
- if (date != null)
- {
- int current = date.getYear();
- if ((first == null) || (first < current))
- {
- first = current;
- }
- }
- }
-
- result = htmlizeServiceCountYearChart(services, first);
-
- //
- return result;
- }
-
- /**
- * Htmlize service count chart.
- *
- * @param services
- * the services
- * @param first
- * the first
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceCountYearChart(final Services services, final int first) throws StatoolInfosException
- {
- String result;
-
- BarChart chart;
-
- chart = new BarChart("Nombre de services");
- chart.addDataset("Services");
-
- int now = LocalDate.now().getYear();
- int current = first;
- while (current <= now)
- {
- long count = 0;
- for (Service service : services)
- {
- LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate());
- LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate());
-
- if (startDate != null)
- {
- int start = startDate.getYear();
- int end;
- if (endDate == null)
- {
- end = now;
- }
- else
- {
- end = endDate.getYear();
- }
-
- if ((current >= start) && (current <= end))
- {
- count += 1;
- }
- }
- }
-
- chart.add(String.valueOf(current), count, ChartColor.VIOLET);
-
- current += 1;
- }
-
- result = BarChartView.build(chart);
-
- //
- return result;
- }
-
- /**
- * Htmlize service date status chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceDateStatusChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- PieChart pie = new PieChart("Services avec ou sans date");
-
- long filled = 0;
- long unfilled = 0;
- for (Service service : services)
- {
- if (StatoolInfosUtils.parseDate(service.getStartDate()) == null)
- {
- unfilled += 1;
- }
- else
- {
- filled += 1;
- }
- }
-
- pie.add("Avec", filled, ChartColor.VIOLET);
- pie.add("Sans", unfilled, ChartColor.BLUE);
-
- pie.setLegendPosition(Position.RIGHT);
-
- result = PieChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * Htmlize service install type chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeServiceInstallTypeChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- ServiceInstallTypeStats stats = StatAgent.statServiceInstallType(services);
-
- PieChart pie = new PieChart("Types d'installation du service");
- pie.add("Distribution", stats.getDistributionCount(), ChartColor.PURPLE);
- pie.add("Fournisseur", stats.getProviderCount(), ChartColor.GREEN);
- pie.add("Paquet", stats.getPackageCount(), ChartColor.YELLOW);
- pie.add("Outillage", stats.getToolingCount(), ChartColor.ORANGE);
- pie.add("Dépôt cloné", stats.getClonerepoCount(), ChartColor.RED);
- pie.add("Archive", stats.getArchiveCount(), ChartColor.VIOLET);
- pie.add("Sources", stats.getSourcesCount(), ChartColor.GREY);
- pie.add("Containeur", stats.getContainerCount(), ChartColor.TURQUOISE);
- pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE);
- pie.setLegendPosition(Position.RIGHT);
-
- result = DoughnutChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * Htmlize software distribution chart.
- *
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeSoftwareDistributionChart() throws StatoolInfosException
- {
- String result;
-
- BarChart chart = new BarChart("Distribution des logiciels proposés par au moins deux services");
- chart.addDataset("Logiciel");
-
- Federation federation = HtmlizerContext.instance().getFederation();
- Categories categories = HtmlizerContext.instance().getCategories();
-
- SoftwareStats stats = StatAgent.statAllSoftwares(federation, categories);
- stats.sortByServiceCount().reverse();
-
- for (SoftwareStat stat : stats)
- {
- if (stat.getServiceCount() > 1)
- {
- chart.add(stat.getName(), stat.getServiceCount(), ChartColor.PURPLE);
- }
- }
-
- result = BarChartView.build(chart);
-
- //
- return result;
- }
-
- /**
- * Htmlize software used chart.
- *
- * @param services
- * the services
- * @return the string
- * @throws StatoolInfosException
- * the statool infos exception
- */
- public static String htmlizeSoftwareDistributionPieChart(final Services services) throws StatoolInfosException
- {
- String result;
-
- Federation federation = HtmlizerContext.instance().getFederation();
- Categories categories = HtmlizerContext.instance().getCategories();
-
- SoftwareStats stats = StatAgent.statAllSoftwares(federation, categories);
- stats.sortByServiceCount().reverse();
-
- ChartColors colors = ChartColor.valueList();
- colors.remove(ChartColor.BLUE);
-
- PieChart pie = new PieChart("Répartition des services par logiciel");
- int index = 0;
- while ((index < stats.size() && (index < 10)))
- {
- ChartColor color = colors.get(index);
- SoftwareStat stat = stats.get(index);
- pie.add(stat.getName(), stat.getServiceCount(), color);
-
- index += 1;
- }
-
- int others = 0;
- while (index < stats.size())
- {
- SoftwareStat stat = stats.get(index);
- others += stat.getServiceCount();
-
- index += 1;
- }
- pie.add("Autres", others, ChartColor.BLUE);
- pie.setLegendPosition(Position.RIGHT);
-
- result = DoughnutChartView.build(pie);
-
- //
- return result;
- }
-
- /**
- * To bar chart.
- *
- * @param stats
- * the stats
- * @return the bar chart
- */
- public static BarChart toBarChart(final RegistrationStats stats)
- {
- BarChart result;
-
- result = new BarChart("Types d'inscription");
- result.addDataset("Nombre");
- result.add("Sans", stats.getNoneCount(), ChartColor.GREEN);
- result.add("Libre", stats.getFreeCount(), ChartColor.YELLOW);
- result.add("Membre", stats.getMemberCount(), ChartColor.ORANGE);
- result.add("Client", stats.getClientCount(), ChartColor.RED);
- result.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE);
-
- //
- return result;
- }
}
diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java
index d33d292..ca6b876 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java
@@ -30,11 +30,6 @@ import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
-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.DoughnutChartView;
-import fr.devinsy.statoolinfos.htmlize.charts.PieChart;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
import fr.devinsy.xidyn.XidynException;
@@ -84,46 +79,25 @@ public class OrganizationStatsPage
TagDataManager data = new TagDataManager();
- data.setContent("serviceCountYearChart", Htmlizer.htmlizeServiceCountYearChart(organization));
- data.setContent("serviceDateStatusChart", Htmlizer.htmlizeServiceDateStatusChart(organization.getServices()));
+ data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization));
+ data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(organization.getServices()));
- data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(organization));
+ data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organization));
- 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()));
+ data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(organization.getServices()));
+ data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(organization.getServices()));
+ data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(organization.getServices()));
+ data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(organization.getServices()));
//
{
RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices());
- BarChart bar = Htmlizer.toBarChart(stats);
- data.setContent("registrationTypeChart", BarChartView.build(bar));
-
- PieChart pie = new PieChart("Sans");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getNoneCount(), ChartColor.GREEN);
- pie.add("Autre", stats.getCount() - stats.getNoneCount(), ChartColor.BLUE);
- data.setContent("registrationNoneTypeChart", DoughnutChartView.build(pie));
-
- pie = new PieChart("Libre");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getFreeCount(), ChartColor.YELLOW);
- pie.add("Libre", stats.getCount() - stats.getFreeCount(), ChartColor.BLUE);
- data.setContent("registrationFreeTypeChart", DoughnutChartView.build(pie));
-
- pie = new PieChart("Membre");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getMemberCount(), ChartColor.ORANGE);
- pie.add("Membre", stats.getCount() - stats.getMemberCount(), ChartColor.BLUE);
- data.setContent("registrationMemberTypeChart", DoughnutChartView.build(pie));
-
- pie = new PieChart("Client");
- pie.setLegendVisible(false);
- pie.add("Sans", stats.getClientCount(), ChartColor.RED);
- pie.add("Client", stats.getCount() - stats.getClientCount(), ChartColor.BLUE);
- data.setContent("registrationClientTypeChart", DoughnutChartView.build(pie));
+ data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats));
+ data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats));
+ data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats));
+ data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats));
+ data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats));
}
//