| 122 | } |
| 123 | |
| 124 | std::string box_chart::data_string() { |
| 125 | if (x_data_.empty()) { |
| 126 | x_data_ = std::vector<double>(y_data_.size(), 1.0); |
| 127 | } |
| 128 | std::vector<double> unique_groups = unique(x_data_); |
| 129 | std::stringstream ss; |
| 130 | ss.precision(10); |
| 131 | ss << std::fixed; |
| 132 | // for each group |
| 133 | for (size_t i = 0; i < unique_groups.size(); ++i) { |
| 134 | // for each point |
| 135 | for (size_t j = 0; j < y_data_.size(); ++j) { |
| 136 | // if point is part of this group |
| 137 | if (unique_groups[i] == x_data_[j]) { |
| 138 | ss << " " << unique_groups[i] << " " << y_data_[j] |
| 139 | << " " << box_width_ << "\n"; |
| 140 | } |
| 141 | } |
| 142 | ss << "e\n"; |
| 143 | } |
| 144 | return ss.str(); |
| 145 | } |
| 146 | |
| 147 | bool box_chart::requires_colormap() { return false; } |
| 148 | |