From 8c23fc3e5bfa104183b7ebf9358531ca0cc03db3 Mon Sep 17 00:00:00 2001 From: MokeevNV Date: Fri, 16 May 2025 12:03:31 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D1=89=D0=B8=D1=82=D1=8B=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svg.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/svg.cpp b/svg.cpp index 149f2cd..d8fe23a 100644 --- a/svg.cpp +++ b/svg.cpp @@ -1,4 +1,5 @@ #include "svg.h" +#include "histogram_internal.h" #include #include @@ -31,25 +32,18 @@ void show_histogram_svg(const vector& bins) { const auto TEXT_BASELINE = 20; const auto TEXT_WIDTH = 50; const auto BIN_HEIGHT = 30; - - size_t max_count = 0; - for (size_t count : bins) { - if (count > max_count) { - max_count = count; - } - } - - double BLOCK_WIDTH = (IMAGE_WIDTH - TEXT_WIDTH) / static_cast(max_count); + const auto BLOCK_WIDTH = 10; svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT); double top = 0; for (size_t bin : bins) { - double bin_width = BLOCK_WIDTH * bin; + 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, "black", "#aaaaaa"); + svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT); top += BIN_HEIGHT; } - svg_end(); } + +