From 07450fbaaca317b38143ba485ec5cdfbd666ac22 Mon Sep 17 00:00:00 2001 From: GordiyevskikDA Date: Sat, 16 Mar 2024 16:48:46 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=BE=20=D0=BC=D0=B0=D1=81=D1=88=D1=82?= =?UTF-8?q?=D0=B0=D0=B1=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B3=D0=B8=D1=81=D1=82=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LABA1.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/LABA1.cpp b/LABA1.cpp index cfa8558..88b7ac6 100644 --- a/LABA1.cpp +++ b/LABA1.cpp @@ -19,7 +19,7 @@ void svg_text(double left, double baseline, string text) { cout << "" << text <<"\n"; } -void svg_rect(double x, double y, double width, double height, string stroke = "red", string fill = "red") { +void svg_rect(double x, double y, double width, double height, string stroke = "yellow", string fill = "red") { cout << "\n"; } @@ -35,12 +35,16 @@ void show_histogram_svg(const vector& marks, const vector& chart const auto TEXT_WIDTH = 50; const auto BIN_HEIGHT = 30; const auto BLOCK_WIDTH = 10; - svg_begin(400, 300); + double min = 0, max = 0, scale = 1; + int maxlen = IMAGE_WIDTH - TEXT_WIDTH; + svg_begin(4000, 300); double top = 0; + FindMinMax(chart, min, max); + scale = max * BLOCK_WIDTH / maxlen; for (double bin : chart) { - const double bin_width = BLOCK_WIDTH * bin; + double bin_width = BLOCK_WIDTH * bin; svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string((int)bin)); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT); + svg_rect(TEXT_WIDTH, top, bin_width / scale, BIN_HEIGHT); top += BIN_HEIGHT; } svg_end();