|
|
|
@ -20,10 +20,9 @@ svg_end()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
svg_text(double left, double baseline, string text)
|
|
|
|
|
svg_text(double left, double baseline, string text, string decoration = "none")
|
|
|
|
|
{
|
|
|
|
|
cout << "<text x='" << left << "' y='" << baseline << "'>" << text << "</text>";
|
|
|
|
|
|
|
|
|
|
cout << "<text x='" << left << "' y='" << baseline << "' " << "style='text-decoration: " << decoration << "'>" << text << "</text>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void svg_rect(double x, double y, double width, double height,
|
|
|
|
@ -33,7 +32,7 @@ void svg_rect(double x, double y, double width, double height,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
show_histogram_svg(const vector<size_t>& bins)
|
|
|
|
|
show_histogram_svg(const vector<size_t>& bins, const string& text_decoration)
|
|
|
|
|
{
|
|
|
|
|
const auto IMAGE_WIDTH = 400;
|
|
|
|
|
const auto IMAGE_HEIGHT = 300;
|
|
|
|
@ -66,17 +65,14 @@ for (size_t bin : bins)
|
|
|
|
|
double top = 0;
|
|
|
|
|
for (size_t bin : bins)
|
|
|
|
|
{ if (bin == max) {
|
|
|
|
|
const double bin_width = BLOCK_WIDTH * bin;
|
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
|
svg_rect(TEXT_WIDTH, top, MAX_WIDTH, BIN_HEIGHT);
|
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
const double bin_width = BLOCK_WIDTH * bin;
|
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
|
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin), text_decoration);
|
|
|
|
|
svg_rect(TEXT_WIDTH, top, MAX_WIDTH, BIN_HEIGHT);
|
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
|
} else {
|
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin), text_decoration);
|
|
|
|
|
svg_rect(TEXT_WIDTH, top, BLOCK_WIDTH, BIN_HEIGHT);
|
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
svg_end();
|
|
|
|
|
}
|
|
|
|
|