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++;