4#include <unordered_map>
12 namespace datastructure {
53 std::string tooltipSuffix;
54 std::string orientation;
56 std::vector<std::pair<string, vector<double >>> seriesData;
57 std::vector<std::string> categories;
69 orientation =
"horizontal";
161 if (orient !=
"horizontal" && orient !=
"vertical")
162 throw std::invalid_argument(
"Orientation should be \"horizontal\" or \"vertical\".");
163 orientation = orient;
183 tooltipSuffix = suffix;
192 return tooltipSuffix;
203 if (seriesData.size() > 0)
204 throw std::runtime_error (
"Can't change categoriess after series have been added.");
205 this->categories = categories;
221 if (data.size() != categories.size())
222 throw std::runtime_error (
"The data vector should have the same size as the number of categories.");
224 for (
auto& entry : seriesData) {
225 std::string key = entry.first;
226 if (key == seriesName)
227 throw std::runtime_error (
"Can't have two series with the same name.");
230 seriesData.push_back(std::make_pair(seriesName, data));
241 std::string bins =
"";
243 for (
auto& entry : categories) {
246 bins = bins.erase(bins.length() - 1);
249 std::string series =
"";
251 for (
auto& entry : seriesData) {
253 std::string key = entry.first;
254 std::vector<double> value = entry.second;
257 for (
int i = 0; i < value.size(); i++) {
260 series = series.erase(series.length() - 1);
263 series = series.erase(series.length() - 1);
Support for drawing Bar charts.
Definition: BarChart.h:47
void setBarOrientation(const std::string &orient)
sets the bar chart orientation
Definition: BarChart.h:160
BarChart()
makes an empty BarChart
Definition: BarChart.h:63
std::string getCategoriesLabel() const
Returns the axis label for the categories.
Definition: BarChart.h:151
std::string getTitle() const
Get title of the plot.
Definition: BarChart.h:97
void setCategories(const std::vector< std::string > &categories)
set the categories for this bar chart
Definition: BarChart.h:202
void setTooltipSuffix(const std::string &suffix)
sets the tooltip suffix
Definition: BarChart.h:182
std::string getSubTitle() const
get the subtitle of the plot
Definition: BarChart.h:115
virtual const std::string getDataStructureRepresentation() const override
get the data structure representation as a JSON
Definition: BarChart.h:239
std::string getBarOrientation() const
gets the bar chart orientation
Definition: BarChart.h:171
void addDataSeries(std::string seriesName, std::vector< double > data)
Add a series of data.
Definition: BarChart.h:220
void setTitle(std::string t)
Set title of the plot.
Definition: BarChart.h:88
void setValueLabel(const std::string &vAxisName)
Set the label for the value axis.
Definition: BarChart.h:124
std::string getTooltipSuffix() const
gets the tooltip suffix
Definition: BarChart.h:191
std::string getValueLabel() const
Returns the label for the value axis.
Definition: BarChart.h:133
void setCategoriesLabel(const std::string &cAxisName)
Change the label for category axis.
Definition: BarChart.h:142
virtual const string getDStype() const override
Get the data type.
Definition: BarChart.h:79
void setSubTitle(const std::string &s)
set subtitle of the plot
Definition: BarChart.h:106
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
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
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