Alice (SemenovIA) 7 месяцев назад
Родитель 46ae64166f
Сommit 117884605d

@ -32,7 +32,18 @@
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="histogram.cpp" />
<Unit filename="histogram.h" />
<Unit filename="histogram_internal.h" />
<Unit filename="main.cpp" />
<Unit filename="percent.cpp" />
<Unit filename="percent.h" />
<Unit filename="show_histogram.cpp" />
<Unit filename="show_svg.h" />
<Unit filename="svg.cpp" />
<Unit filename="svg.h" />
<Unit filename="text.cpp" />
<Unit filename="text.h" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>

@ -1,5 +1,5 @@
#include "svg.h"
#include "percent.h"
void
show_histogram_svg(const vector<size_t>& bins) {
@ -32,7 +32,7 @@ show_histogram_svg(const vector<size_t>& bins) {
const double bin_width = BLOCK_WIDTH * bin;
if (bin == longest){
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
svg_rect(TEXT_WIDTH, top, IMAGE_WIDTH - 2*TEXT_WIDTH, BIN_HEIGHT, "#000000", "#ff00a2");
svg_rect(TEXT_WIDTH, top, IMAGE_WIDTH - TEXT_WIDTH, BIN_HEIGHT, "#000000", "#ff00a2");
top += BIN_HEIGHT;
} else{
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
@ -40,11 +40,5 @@ show_histogram_svg(const vector<size_t>& bins) {
top += BIN_HEIGHT;
}
}
top = 0;
percent(bins, bins_percent);
for (size_t bin_percent : bins_percent){
svg_text(IMAGE_WIDTH - TEXT_WIDTH + TEXT_LEFT, top + TEXT_BASELINE, to_string(bin_percent)+"%");
top += BIN_HEIGHT;
}
svg_end();
}

@ -39,9 +39,3 @@ TEST_CASE("distinct negative numbers") {
CHECK(min == -4);
CHECK(max == -1.5);
}
TEST_CASE("percent 1") {
const vector<size_t>bins{5, 10, 10, 50, 25};
vector<size_t>bins_percent{};
percent(bins, bins_percent);
CHECK(bins_percent[0] == 5);
}

Загрузка…
Отмена
Сохранить