|
|
@ -28,9 +28,9 @@ svg_rect(double x, double y, double width, double height, string stroke, string
|
|
|
|
cout << "<rect x = '" << x << "' y = '" << y << "' width = '" << width << "' height = '" << height << "' stroke = '" << stroke << "' fill = '" << fil << "' />";
|
|
|
|
cout << "<rect x = '" << x << "' y = '" << y << "' width = '" << width << "' height = '" << height << "' stroke = '" << stroke << "' fill = '" << fil << "' />";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string bin_color(size_t bin, size_t max_count){
|
|
|
|
//string bin_color(size_t bin, size_t max_count){
|
|
|
|
return ("#" + to_string(10 - (bin * 9) / max_count) + to_string(10 - (bin * 9) / max_count) + to_string(10 - (bin * 9) / max_count));
|
|
|
|
// return ("#" + to_string(10 - (bin * 9) / max_count) + to_string(10 - (bin * 9) / max_count) + to_string(10 - (bin * 9) / max_count));
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
show_histogram_svg(const vector<size_t>& bins) {
|
|
|
@ -53,9 +53,9 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
double top = 0;
|
|
|
|
double top = 0;
|
|
|
|
for (size_t bin : bins) {
|
|
|
|
for (size_t bin : bins) {
|
|
|
|
const double bin_width = (IMAGE_WIDTH - TEXT_WIDTH) * bin / max_count;
|
|
|
|
const double bin_width = (IMAGE_WIDTH - TEXT_WIDTH) * bin / max_count;
|
|
|
|
const auto color = bin_color(bin,max_count);
|
|
|
|
//const auto color = bin_color(bin,max_count);
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,"grey", color);
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,"red", "#ffeeee");
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
svg_end();
|
|
|
|
svg_end();
|
|
|
|