4 #include <unordered_map>
47 namespace datastructure {
55 std::string tooltipSuffix;
56 std::string orientation;
58 std::vector<std::pair<string, vector<double >>> seriesData;
59 std::vector<std::string> categories;
68 orientation =
"horizontal";
157 if (orient !=
"horizontal" && orient !=
"vertical")
158 throw std::invalid_argument(
"Orientation should be \"horizontal\" or \"vertical\".");
159 orientation = orient;
179 tooltipSuffix = suffix;
188 return tooltipSuffix;
199 if (seriesData.size() > 0)
200 throw std::runtime_error (
"Can't change categoriess after series have been added.");
201 this->categories = categories;
217 if (data.size() != categories.size())
218 throw std::runtime_error (
"The data vector should have the same size as the number of categories.");
220 for (
auto& entry : seriesData) {
221 std::string key = entry.first;
222 if (key == seriesName)
223 throw std::runtime_error (
"Can't have two series with the same name.");
226 seriesData.push_back(std::make_pair(seriesName, data));
234 std::string bins =
"";
236 for (
auto& entry : categories) {
239 bins = bins.erase(bins.length() - 1);
242 std::string series =
"";
244 for (
auto& entry : seriesData) {
246 std::string key = entry.first;
247 std::vector<double> value = entry.second;
250 for (
int i = 0; i < value.size(); i++) {
253 series = series.erase(series.length() - 1);
256 series = series.erase(series.length() - 1);
Definition: BarChart.h:49
void setBarOrientation(const std::string &orient)
sets the bar chart orientation
Definition: BarChart.h:156
void setCategories(std::vector< std::string > categories)
set the categories for this bar chart
Definition: BarChart.h:198
BarChart()
Definition: BarChart.h:62
std::string getCategoriesLabel() const
Returns the axis label for the categories.
Definition: BarChart.h:147
std::string getTitle() const
Title of the plot.
Definition: BarChart.h:93
void setTooltipSuffix(const std::string &suffix)
sets the tooltip suffix
Definition: BarChart.h:178
std::string getSubTitle() const
get the subtitle of the plot
Definition: BarChart.h:111
virtual const std::string getDataStructureRepresentation() const override
get the data structure representation as a JSON
Definition: BarChart.h:232
std::string getBarOrientation() const
gets the bar chart orientation
Definition: BarChart.h:167
void addDataSeries(std::string seriesName, std::vector< double > data)
Add a series of data.
Definition: BarChart.h:216
void setTitle(std::string t)
Title of the plot.
Definition: BarChart.h:84
void setValueLabel(const std::string &vAxisName)
Change the label for the value axis.
Definition: BarChart.h:120
std::string getTooltipSuffix() const
gets the tooltip suffix
Definition: BarChart.h:187
std::string getValueLabel() const
Returns the label for the value axis.
Definition: BarChart.h:129
void setCategoriesLabel(const std::string &cAxisName)
Change the label for categoryt axis.
Definition: BarChart.h:138
virtual const string getDStype() const override
Get the data type.
Definition: BarChart.h:75
void setSubTitle(const std::string &s)
set subtitle of the plot
Definition: BarChart.h:102
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:74
std::string JSONencode(const T &d)
Definition: JSONutil.h:38
Support for drawing Bar charts.
Definition: alltypes.h:4
const string COLON
Definition: DataStructure.h:52
const string OPEN_BOX
Definition: DataStructure.h:55
const string COMMA
Definition: DataStructure.h:51
const string OPEN_CURLY
Definition: DataStructure.h:53
const string CLOSE_BOX
Definition: DataStructure.h:56
const string CLOSE_CURLY
Definition: DataStructure.h:54