From 99404971c05bb13bcaf1809796d3669ef97e569c Mon Sep 17 00:00:00 2001 From: "Dmitriy (BerezhkovDA)" Date: Sat, 4 May 2024 18:28:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=BD=D0=B4=D0=B8=D0=B2=D0=B8=D0=B4?= =?UTF-8?q?=D1=83=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=D0=B7=D0=B0=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD?= =?UTF-8?q?=D1=82=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sem2_lab1/svg.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sem2_lab1/svg.cpp b/sem2_lab1/svg.cpp index 2d81807..4eaf174 100644 --- a/sem2_lab1/svg.cpp +++ b/sem2_lab1/svg.cpp @@ -36,10 +36,11 @@ void show_histogram_svg(const vector& bins, int number_cnt) { double max = bins[0]; for (size_t bin : bins) if (bin > max) max = bin; cout << max; - double k = (IMAGE_WIDTH - TEXT_WIDTH) / max; + double k = (IMAGE_WIDTH - TEXT_WIDTH*2) / max; for (size_t bin : bins) { const double bin_width = k * bin; svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); + svg_text(IMAGE_WIDTH - TEXT_WIDTH + TEXT_LEFT, top + TEXT_BASELINE, to_string((int)((100.0 / (double)number_cnt) * (double)bin)) + "%"); svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,"black",colors[color_ptr]); top += BIN_HEIGHT; color_ptr++;