diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java deleted file mode 100644 index 07f2b6e..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2020 Christian Pierre MOMON - * - * 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 . - */ -package fr.devinsy.statoolinfos.htmlize.charts; - -import java.io.IOException; -import java.time.LocalDate; - -import org.apache.commons.codec.digest.DigestUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.metrics.Metric; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class projectsRawPageBuilder. - */ -public class BarMonthsChartView -{ - private static Logger logger = LoggerFactory.getLogger(BarMonthsChartView.class); - - /** - * Builds the. - * - * @param metric - * the metric - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final Metric metric) throws StatoolInfosException - { - String result; - - result = build(metric, ChartColor.BLUE); - - // - return result; - } - - /** - * Builds the. - * - * @param metric - * the metric - * @return the string - * @throws StatoolInfosException - */ - public static String build(final Metric metric, final ChartColor color) throws StatoolInfosException - { - String result; - - LocalDate start = LocalDate.parse(metric.getStartYear() + "-01-01"); - LocalDate end = start.plusMonths(metric.getMonthValues().size() - 1); - StringList labels = ChabuUtils.buildYearMonthAlphaLabels(start, end); - - result = build(metric.getName(), metric.getDescription(), labels, metric.getMonthValues(), color); - - // - return result; - } - - /** - * Builds the. - * - * @param title - * the title - * @param description - * the description - * @param labels - * the labels - * @param values - * the values - * @param color - * the color - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final String title, final String description, final StringList labels, final StringList values, final ChartColor color) throws StatoolInfosException - { - String result; - try - { - String source = XidynUtils.load(ChabuUtils.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml")); - String code = XidynUtils.extractBodyContent(source); - - code = code.replace("rgb(54, 162, 235)", color.code()); - code = code.replace("rgb(54, 162, 235, 0.2)", color.light()); - code = code.replace("description", XidynUtils.escapeXmlBlank(description)); - code = code.replace("myChart", "myChart_" + DigestUtils.sha1Hex(title + "barMonthsChart")); - code = code.replace("# of Votes", title.replace("'", "\\\\'")); - code = code.replaceFirst("labels: \\[.*\\]", "labels: " + ChabuUtils.toJSonStrings(labels)); - code = code.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(values)); - - result = code.toString(); - } - catch (IOException exception) - { - throw new StatoolInfosException("Error building bar months chart view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarTimeChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarTimeChartView.java deleted file mode 100644 index 6b2bcff..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarTimeChartView.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2020 Christian Pierre MOMON - * - * 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 . - */ -package fr.devinsy.statoolinfos.htmlize.charts; - -import java.io.IOException; - -import org.apache.commons.codec.digest.DigestUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class BarTimeChartView. - */ -public class BarTimeChartView -{ - private static Logger logger = LoggerFactory.getLogger(BarTimeChartView.class); - - /** - * Builds the. - * - * @param title - * the title - * @param labelTitle - * the label title - * @param labels - * the labels - * @param values - * the values - * @return the string - * @throws AgirStatoolException - * the agir statool exception - */ - public static String build(final String title, final String labelTitle, final StringList labels, final StringList values) throws StatoolInfosException - { - String result; - - try - { - String source = XidynUtils.load(ChabuUtils.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml")); - String code = XidynUtils.extractBodyContent(source); - - code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "chartBar")); - code = code.replace("# of Votes", labelTitle); - code = code.replaceAll("labels: \\[.*\\]", "labels: " + ChabuUtils.toJSonStrings(labels)); - code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(values)); - - result = code.toString(); - } - catch (IOException exception) - { - throw new StatoolInfosException("Error building ProjectsRaw view: " + exception.getMessage(), exception); - } - - // - return result; - } -}