From f7cd78c7b9aa445ac149da6bf5c8f85e22e9bca5 Mon Sep 17 00:00:00 2001 From: "Igor (ZharkovIG)" Date: Sun, 20 Oct 2024 02:45:50 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=B8=D0=BD=D0=B4=D0=B8=D0=B2=D0=B8=D0=B4=D1=83=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svg.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/svg.cpp b/svg.cpp index 2fd73bb..9b893e8 100644 --- a/svg.cpp +++ b/svg.cpp @@ -32,7 +32,8 @@ void show_histogram_svg(const vector& bins) { const auto IMAGE_WIDTH = 400; const auto IMAGE_HEIGHT = 300; - const auto TEXT_LEFT = 20; + const auto IMAGE_LEFT = 20; + const auto TEXT_LEFT = 30; const auto TEXT_BASELINE = 20; const auto TEXT_WIDTH = 50; const auto BIN_HEIGHT = 30; @@ -50,8 +51,9 @@ show_histogram_svg(const vector& bins) { double top = 0; 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","#ffeeee"); + const double text_left = bin_width + TEXT_LEFT; + svg_rect(IMAGE_LEFT, top, bin_width, BIN_HEIGHT,"red","#ffeeee"); + svg_text(text_left, top + TEXT_BASELINE, to_string(bin)); top += BIN_HEIGHT; } svg_end();