|
|
@ -30,7 +30,7 @@ cout << "<rect x='" << x << "' y='" << y << "' width='" << width * 3 << "' heigh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
show_histogram_svg(const vector<size_t>& bins, const vector<string>& colour) {
|
|
|
|
|
|
|
|
|
|
|
|
const auto IMAGE_WIDTH = 400;
|
|
|
|
const auto IMAGE_WIDTH = 400;
|
|
|
|
const auto IMAGE_HEIGHT = 300;
|
|
|
|
const auto IMAGE_HEIGHT = 300;
|
|
|
@ -42,10 +42,10 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
|
|
|
|
|
|
|
|
svg_begin(400, 300);
|
|
|
|
svg_begin(400, 300);
|
|
|
|
double top = 0;
|
|
|
|
double top = 0;
|
|
|
|
for (size_t bin : bins) {
|
|
|
|
for (size_t i=0; i< bins.size(); i++) {
|
|
|
|
const double bin_width = BLOCK_WIDTH * bin;
|
|
|
|
const double bin_width = BLOCK_WIDTH * bins[i];
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i]));
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "#ffeeee");
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", colour[i]);
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
svg_end();
|
|
|
|
svg_end();
|
|
|
|