From 07e52a536945d114e5f0ce85c81056aa0e8265b2 Mon Sep 17 00:00:00 2001 From: KapitonovMikA Date: Mon, 20 May 2024 03:34:25 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BC=D0=B0=D1=81=D1=88=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svg01.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/svg01.cpp b/svg01.cpp index 9aa27ab..f0714c1 100644 --- a/svg01.cpp +++ b/svg01.cpp @@ -42,8 +42,14 @@ show_histogram_svg(const vector& bins) { svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT); double top = 0; + double maxel = bins[0]; for (size_t bin : bins) { - const double bin_width = BLOCK_WIDTH * bin; + if (maxel > bin){ + maxel = bin; + } + } + for (size_t bin : bins) { + const double bin_width = (( IMAGE_WIDTH - TEXT_WIDTH ) / BLOCK_WIDTH ) * ( bin / maxel ); svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT); top += BIN_HEIGHT; @@ -51,3 +57,5 @@ show_histogram_svg(const vector& bins) { svg_end(); } + +