/* * Copyright (C) 2020-2021 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 org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.strings.StringList; /** * The Class BarChart. */ public class BarChart { private static Logger logger = LoggerFactory.getLogger(BarChart.class); private String title; private boolean displayTitle; private StringList labels; private BarChartDatasets datasets; private boolean stacked; private boolean animated; /** * Instantiates a new bar chart. * * @param title * the title */ public BarChart(final String title) { this.title = title; this.displayTitle = true; this.labels = new StringList(); this.datasets = new BarChartDatasets(); this.stacked = false; this.animated = true; } /** * Adds the. * * @param datasetIndex * the dataset index * @param value * the value * @param color * the color */ public void add(final int datasetIndex, final double value, final ChartColor color) { this.datasets.get(datasetIndex).add(new BarChartData(null, value, color)); } /** * Adds the. * * @param label * the label * @param value * the value * @param color * the color */ public void add(final String label, final double value, final ChartColor color) { this.labels.add(label); this.datasets.get(0).add(new BarChartData(label, value, color)); } /** * Adds the dataset. * * @param name * the name * @return the int */ public int addDataset(final String name) { int result; this.datasets.add(new BarChartDataset(name)); result = this.datasets.size() - 1; // return result; } /** * Gets the colors. * * @return the colors */ public ChartColors getColors() { ChartColors result; result = this.datasets.get(0).getColors(); // return result; } /** * Gets the dataset. * * @param index * the index * @return the dataset */ public BarChartDataset getDataset(final int index) { BarChartDataset result; result = this.datasets.get(index); // return result; } public BarChartDatasets getDatasets() { return this.datasets; } /** * Gets the labels. * * @return the labels */ public StringList getLabels() { StringList result; result = this.labels; // return result; } /** * Gets the title. * * @return the title */ public String getTitle() { return this.title; } public boolean isAnimated() { return this.animated; } public boolean isDisplayTitle() { return this.displayTitle; } public boolean isStacked() { return this.stacked; } public void setAnimated(final boolean animated) { this.animated = animated; } public void setDisplayTitle(final boolean displayTitle) { this.displayTitle = displayTitle; } public void setStacked(final boolean stacked) { this.stacked = stacked; } public void setTitle(final String title) { this.title = title; } }