4 #include <unordered_map>
11 namespace datastructure {
55 unordered_map<string, vector<double >> xaxisData;
56 unordered_map<string, vector<double >> yaxisData;
203 void setDataSeries(
string seriesName, vector<double> xdata, vector<double> ydata) {
214 void setXData(
string series, vector<double> xdata) {
215 xaxisData[series] = xdata;
225 return xaxisData[series];
234 void setYData(
string series, vector<double> ydata) {
235 yaxisData[series] = ydata;
245 return yaxisData[series];
262 for (
auto& entry : xaxisData) {
263 string series = entry.first;
264 vector<double> xdata = entry.second;
265 vector<double> ydata = yaxisData.at(series);
267 cout <<
"Series \"" + series +
"\" has xdata but no ydata";
270 if (xdata.size() != ydata.size()) {
271 cout <<
"Series \"" + series +
"\" has xdata and ydata of different sizes";
275 for (
int i = 0; i < xdata.size(); ++i) {
277 cout <<
"Xaxis scale is logarithmic but series \"" + series
278 +
"\" has xdata[" << i <<
"] = " << xdata[i] <<
279 " (should be stricly positive)";
284 for (
int i = 0;
i < ydata.size(); ++
i) {
286 cout <<
"Yaxis scale is logarithmic but series \"" +
287 series +
"\" has ydata[" <<
i <<
"] = " << ydata[
i] <<
288 " (should be stricly positive)";
293 for (
auto& entry : yaxisData) {
294 string series = entry.first;
295 vector<double> ydata = entry.second;
296 vector<double> xdata = xaxisData.at(series);
298 cout <<
"Series: " + series +
" has ydata but no xdata";
310 string xaxis_json =
"";
311 for (
auto& entry : xaxisData) {
312 string key = entry.first;
313 vector<double> value = entry.second;
318 for (
int i = 0; i < value.size() ; i++) {
321 xaxis_json = xaxis_json.erase(xaxis_json.size() - 1);
324 xaxis_json = xaxis_json.erase(xaxis_json.length() - 1);
326 string yaxis_json =
"";
327 for (
auto& entry : yaxisData) {
328 string key = entry.first;
329 vector<double> value = entry.second;
333 for (
int i = 0; i < value.size() ; i++) {
336 yaxis_json = yaxis_json.erase(yaxis_json.length() - 1);
339 yaxis_json = yaxis_json.erase(yaxis_json.length() - 1);
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:74
Show series of data or functions using a line chart.
Definition: LineChart.h:43
string getSubTitle() const
Subtitle of the plot.
Definition: LineChart.h:156
virtual const string getDataStructureRepresentation() const override
Definition: LineChart.h:307
void toggleSeriesLabel(bool val)
Enables or disables series labels.
Definition: LineChart.h:98
void toggleLogarithmicY(bool val)
Change the Y-axis scale to logarithmic.
Definition: LineChart.h:120
virtual const string getDStype() const override
Get the data type.
Definition: LineChart.h:74
void toggleLogarithmicX(bool val)
Change the X-axis scale to logarithmic.
Definition: LineChart.h:109
void setSubTitle(string s)
Subtitle of the plot.
Definition: LineChart.h:147
string getYLabel() const
Returns the label for the Y-axis.
Definition: LineChart.h:174
vector< double > getYData(string series)
Returns the Y data for a series.
Definition: LineChart.h:244
void setYData(string series, vector< double > ydata)
Changes the Y data for a series.
Definition: LineChart.h:234
string getTitle() const
Title of the plot.
Definition: LineChart.h:138
void setXData(string series, vector< double > xdata)
Changes the X data for a series.
Definition: LineChart.h:214
void setXLabel(string xaxisName)
Change the label for the X-axis.
Definition: LineChart.h:183
LineChart()
Definition: LineChart.h:59
string getXLabel() const
Returns the label for the Y-axis.
Definition: LineChart.h:192
void setYLabel(string yaxisName)
Change the label for the Y-axis.
Definition: LineChart.h:165
void setTitle(string t)
Title of the plot.
Definition: LineChart.h:129
void setDataSeries(string seriesName, vector< double > xdata, vector< double > ydata)
Add a series (or update it)
Definition: LineChart.h:203
void toggleMouseTrack(bool val)
Enables or disables mouse tracking.
Definition: LineChart.h:86
vector< double > getXData(string series)
Returns the X data for a series.
Definition: LineChart.h:224
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