Andrey 2 лет назад
Родитель 9138330d43
Сommit d94b3e17d9

@ -25,7 +25,7 @@ svg_text(double left, double baseline, string text) {
}
void svg_rect(double x, double y, double width, double height, string stroke = "black", string fill = "black"){
cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' stroke='" << stroke << "' fill='#" << fill << "' />";
cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' stroke='" << stroke << "' fill='#" << fill << fill << fill << "' />";
}
void
@ -50,20 +50,22 @@ show_histogram_svg(const vector<double>& bins) {
if (bins[j] > maxb) maxb = bins[j];
}
maxb = maxb * BLOCK_WIDTH;
double maxb1 = maxb * BLOCK_WIDTH;
for (size_t bin : bins) {
double bin_width;
if (maxb > MAX_ASTERISK)
int color = (10 - (bin * 9) / maxb);
if (maxb1 > MAX_ASTERISK)
{
bin_width = BLOCK_WIDTH * MAX_ASTERISK * (bin / maxb);
bin_width = BLOCK_WIDTH * MAX_ASTERISK * (bin / maxb1);
}
else bin_width = BLOCK_WIDTH * bin;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "ffeeee");
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "violet", to_string(color));
top += BIN_HEIGHT;
}

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