From 50245be3afa14889ea84ccfac4875f41310a6b70 Mon Sep 17 00:00:00 2001 From: KorneevMA Date: Sun, 29 Sep 2024 23:11:14 +0300 Subject: [PATCH] personal var --- svg.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/svg.cpp b/svg.cpp index 9148803..17659a7 100644 --- a/svg.cpp +++ b/svg.cpp @@ -3,9 +3,9 @@ using namespace std; -const auto IMAGE_WIDTH = 400; -const auto IMAGE_HEIGHT = 300; -const auto TEXT_LEFT = 20; +const auto IMAGE_WIDTH = 300; +const auto IMAGE_HEIGHT = 400; +const auto TEXT_LEFT = 10; const auto TEXT_BASELINE = 20; const auto TEXT_WIDTH = 50; const auto BIN_HEIGHT = 30; @@ -54,8 +54,9 @@ show_histogram_svg(const vector& bins) { double top = 0; for (size_t bin : bins) { const double bin_width = BLOCK_WIDTH * bin; - svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); - svg_rect(TEXT_WIDTH, top, bin_width / scale, BIN_HEIGHT, stroke[i], fill[i]); + double bin_height = bin_width / scale; + svg_text(TEXT_LEFT + top, maxlen + TEXT_BASELINE, to_string(bin)); + svg_rect(top, maxlen - bin_height, BIN_HEIGHT, bin_height, stroke[i], fill[i]); top += BIN_HEIGHT; i++; }