From 20bfa6a5591c3780ac31bd59ab9b933aaa9c92f5 Mon Sep 17 00:00:00 2001 From: Chernov Danila Date: Sun, 23 Apr 2023 20:10:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=20?= =?UTF-8?q?=E2=84=965?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/svg.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/project/svg.cpp b/project/svg.cpp index 7ce10ec..53e46d9 100644 --- a/project/svg.cpp +++ b/project/svg.cpp @@ -36,7 +36,7 @@ void show_histogram_svg(const vector& bins) { const auto IMAGE_WIDTH = 400; const auto IMAGE_HEIGHT = 300; - const auto TEXT_LEFT = 20; + const auto TEXT_LEFT = 10; const auto TEXT_BASELINE = 20; const auto TEXT_WIDTH = 50; const auto BIN_HEIGHT = 30; @@ -53,9 +53,11 @@ double max_count = bins[0]; max_count = bins[i]; } for (size_t bin : bins) { - const double bin_width = (IMAGE_WIDTH - TEXT_WIDTH)*(bin/max_count); - svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "#aaffaa"); + const double bin_width = MAX_WIDTH * (bin/max_count); + const double emptiness_width = MAX_WIDTH - bin_width; + svg_rect(0, top, emptiness_width, BIN_HEIGHT, "white", "#ffffff"); + svg_text(TEXT_LEFT + MAX_WIDTH, top + TEXT_BASELINE, to_string(bin)); + svg_rect(emptiness_width, top, bin_width, BIN_HEIGHT, "red", "#aaffaa"); top += BIN_HEIGHT; }