4 #include <unordered_map> 11 namespace datastructure {
55 unordered_map<string, vector<double>> xaxisData;
56 unordered_map<string, vector<double>> yaxisData;
205 void setDataSeries(
string seriesName, vector<double> xdata, vector<double> ydata) {
217 void setXData(
string series, vector<double> xdata) {
218 xaxisData[series] = xdata;
228 return xaxisData[series];
237 void setYData(
string series, vector<double> ydata) {
238 yaxisData[series] = ydata;
248 return yaxisData[series];
265 for (
auto& entry : xaxisData) {
266 string series = entry.first;
267 vector<double> xdata = entry.second;
268 vector<double> ydata = yaxisData.at(series);
270 cout <<
"Series \"" + series +
"\" has xdata but no ydata";
273 if (xdata.size() != ydata.size()) {
274 cout <<
"Series \"" + series +
"\" has xdata and ydata of different sizes";
278 for (
int i = 0; i < xdata.size(); ++i) {
280 cout <<
"Xaxis scale is logarithmic but series \"" + series
281 +
"\" has xdata[" << i <<
"] = " << xdata[i] <<
282 " (should be stricly positive)";
287 for (
int i = 0; i < ydata.size(); ++i) {
289 cout <<
"Yaxis scale is logarithmic but series \"" +
290 series +
"\" has ydata[" << i <<
"] = " << ydata[i] <<
291 " (should be stricly positive)";
296 for (
auto& entry : yaxisData) {
297 string series = entry.first;
298 vector<double> ydata = entry.second;
299 vector<double> xdata = xaxisData.at(series);
301 cout <<
"Series: " + series +
" has ydata but no xdata";
313 string xaxis_json =
"";
314 for (
auto& entry : xaxisData) {
315 string key = entry.first;
316 vector<double> value = entry.second;
321 for (
int i = 0; i < value.size() ; i++) {
324 xaxis_json = xaxis_json.erase(xaxis_json.size() - 1);
327 xaxis_json = xaxis_json.erase(xaxis_json.length() - 1);
329 string yaxis_json =
"";
330 for (
auto& entry : yaxisData) {
331 string key = entry.first;
332 vector<double> value = entry.second;
336 for (
int i = 0; i < value.size() ; i++) {
339 yaxis_json = yaxis_json.erase(yaxis_json.length() - 1);
342 yaxis_json = yaxis_json.erase(yaxis_json.length() - 1);
void setXLabel(string xaxisName)
Change the label for the X-axis.
Definition: LineChart.h:184
string getYLabel() const
Returns the label for the Y-axis.
Definition: LineChart.h:175
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:73
void toggleLogarithmicY(bool val)
Change the Y-axis scale to logarithmic.
Definition: LineChart.h:120
string getXLabel() const
Returns the label for the Y-axis.
Definition: LineChart.h:193
string getSubTitle() const
Subtitle of the plot.
Definition: LineChart.h:156
const string COLON
Definition: DataStructure.h:51
void toggleLogarithmicX(bool val)
Change the X-axis scale to logarithmic.
Definition: LineChart.h:109
Show series of data or functions using a line chart.
Definition: LineChart.h:43
const string OPEN_BOX
Definition: DataStructure.h:54
string getTitle() const
Title of the plot.
Definition: LineChart.h:138
const string CLOSE_CURLY
Definition: DataStructure.h:53
void setXData(string series, vector< double > xdata)
Changes the X data for a series.
Definition: LineChart.h:217
virtual const string getDataStructureRepresentation() const override
Definition: LineChart.h:310
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 OPEN_CURLY
Definition: DataStructure.h:52
void setDataSeries(string seriesName, vector< double > xdata, vector< double > ydata)
Add a series (or update it)
Definition: LineChart.h:205
const string CLOSE_BOX
Definition: DataStructure.h:55
void setTitle(string t)
Title of the plot.
Definition: LineChart.h:129
void toggleMouseTrack(bool val)
Enables or disables mouse tracking.
Definition: LineChart.h:86
void setSubTitle(string s)
Subtitle of the plot.
Definition: LineChart.h:147
vector< double > getYData(string series)
Returns the Y data for a series.
Definition: LineChart.h:247
virtual const string getDStype() const override
Get the data type.
Definition: LineChart.h:74
void setYData(string series, vector< double > ydata)
Changes the Y data for a series.
Definition: LineChart.h:237
void toggleSeriesLabel(bool val)
Enables or disables series labels.
Definition: LineChart.h:98
const string COMMA
Definition: DataStructure.h:50
void setYLabel(string yaxisName)
Change the label for the Y-axis.
Definition: LineChart.h:166
vector< double > getXData(string series)
Returns the X data for a series.
Definition: LineChart.h:227
std::string JSONencode(const T &d)
Definition: JSONutil.h:37
LineChart()
Definition: LineChart.h:59