4#include <unordered_map>
11 namespace datastructure {
58 unordered_map<string, vector<double >> xaxisData;
59 unordered_map<string, vector<double >> yaxisData;
60 unordered_map<string, int> line_width;
206 line_width[series] = w;
215 return line_width[series];
225 void setDataSeries(
string seriesName, vector<double> xdata, vector<double> ydata) {
228 line_width[seriesName] = 1;
237 void setXData(
string series, vector<double> xdata) {
238 xaxisData[series] = xdata;
248 return xaxisData[series];
257 void setYData(
string series, vector<double> ydata) {
258 yaxisData[series] = ydata;
268 return yaxisData[series];
285 for (
auto& entry : xaxisData) {
286 string series = entry.first;
287 vector<double> xdata = entry.second;
288 vector<double> ydata = yaxisData.at(series);
290 cout <<
"Series \"" + series +
"\" has xdata but no ydata";
293 if (xdata.size() != ydata.size()) {
294 cout <<
"Series \"" + series +
"\" has xdata and ydata of different sizes";
298 for (
int i = 0; i < xdata.size(); ++i) {
300 cout <<
"Xaxis scale is logarithmic but series \"" + series
301 +
"\" has xdata[" << i <<
"] = " << xdata[i] <<
302 " (should be stricly positive)";
307 for (
int i = 0;
i < ydata.size(); ++
i) {
309 cout <<
"Yaxis scale is logarithmic but series \"" +
310 series +
"\" has ydata[" <<
i <<
"] = " << ydata[
i] <<
311 " (should be stricly positive)";
316 for (
auto& entry : yaxisData) {
317 string series = entry.first;
318 vector<double> ydata = entry.second;
319 vector<double> xdata = xaxisData.at(series);
321 cout <<
"Series: " + series +
" has ydata but no xdata";
333 string xaxis_json =
"";
334 for (
auto& entry : xaxisData) {
335 string key = entry.first;
336 vector<double> value = entry.second;
338 xaxis_json +=
OPEN_CURLY + JSONencode(
"Plot_Name")
341 for (
int i = 0; i < value.size() ; i++) {
342 xaxis_json += JSONencode(value[i]) +
COMMA;
344 xaxis_json = xaxis_json.erase(xaxis_json.size() - 1);
347 xaxis_json = xaxis_json.erase(xaxis_json.length() - 1);
349 string yaxis_json =
"";
350 for (
auto& entry : yaxisData) {
351 string key = entry.first;
352 vector<double> value = entry.second;
353 yaxis_json +=
OPEN_CURLY + JSONencode(
"Plot_Name")
356 for (
int i = 0; i < value.size() ; i++) {
357 yaxis_json += JSONencode(value[i]) +
COMMA;
359 yaxis_json = yaxis_json.erase(yaxis_json.length() - 1);
362 yaxis_json = yaxis_json.erase(yaxis_json.length() - 1);
366 for (
auto k: line_width) {
369 lw_json = lw_json.erase(lw_json.length()-1);
377 JSONencode(
"xaxisType") +
COLON + JSONencode(logarithmicx) +
COMMA +
378 JSONencode(
"yaxisType") +
COLON + JSONencode(logarithmicy) +
COMMA +
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:46
string getSubTitle() const
Subtitle of the plot.
Definition LineChart.h:160
int getLineWidth(string series)
Title of the plot.
Definition LineChart.h:214
virtual const string getDataStructureRepresentation() const override
Definition LineChart.h:330
void toggleSeriesLabel(bool val)
Enables or disables series labels.
Definition LineChart.h:102
void toggleLogarithmicY(bool val)
Change the Y-axis scale to logarithmic.
Definition LineChart.h:124
virtual const string getDStype() const override
Get the data type.
Definition LineChart.h:78
void toggleLogarithmicX(bool val)
Change the X-axis scale to logarithmic.
Definition LineChart.h:113
void setSubTitle(string s)
Subtitle of the plot.
Definition LineChart.h:151
string getYLabel() const
Returns the label for the Y-axis.
Definition LineChart.h:178
void setLineWidth(string series, int w)
width of line segments in the plot
Definition LineChart.h:205
void setYData(string series, vector< double > ydata)
Changes the Y data for a series.
Definition LineChart.h:257
string getTitle() const
Title of the plot.
Definition LineChart.h:142
void setXData(string series, vector< double > xdata)
Changes the X data for a series.
Definition LineChart.h:237
void setXLabel(string xaxisName)
Change the label for the X-axis.
Definition LineChart.h:187
LineChart()
Definition LineChart.h:63
string getXLabel() const
Returns the label for the Y-axis.
Definition LineChart.h:196
void setYLabel(string yaxisName)
Change the label for the Y-axis.
Definition LineChart.h:169
void setTitle(string t)
Title of the plot.
Definition LineChart.h:133
void setDataSeries(string seriesName, vector< double > xdata, vector< double > ydata)
Add a series (or update it)
Definition LineChart.h:225
vector< double > getYData(string series)
Returns the Y data for a series.
Definition LineChart.h:267
vector< double > getXData(string series)
Returns the X data for a series.
Definition LineChart.h:247
void toggleMouseTrack(bool val)
Enables or disables mouse tracking.
Definition LineChart.h:90
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
const string QUOTE
Definition DataStructure.h:50