|
|
|
@ -26,16 +26,36 @@ void svg_rect(double x, double y, double width, double height){
|
|
|
|
|
std::cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << " ' stroke='#561A75' fill='#EDB1DB' ></rect>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double
|
|
|
|
|
get_block_width() {
|
|
|
|
|
double BLOCK_WIDTH;
|
|
|
|
|
do {
|
|
|
|
|
std::cerr << "Enter width of one historgamm block (from 3 to 30): ";
|
|
|
|
|
std::cin >> BLOCK_WIDTH;
|
|
|
|
|
if (BLOCK_WIDTH < 3) {
|
|
|
|
|
std::cerr << "The block width cannot be less than 3px. Enter the value again.\n";
|
|
|
|
|
}
|
|
|
|
|
else if (BLOCK_WIDTH > 30) {
|
|
|
|
|
std::cerr << "The block width cannot be more than 30px. Enter the value again.\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} while (BLOCK_WIDTH < 3 || BLOCK_WIDTH > 30);
|
|
|
|
|
return BLOCK_WIDTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
show_histogram_svg(const std::vector<std::size_t>& bins) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto IMAGE_WIDTH = 400;
|
|
|
|
|
const auto IMAGE_HEIGHT = 300;
|
|
|
|
|
const auto TEXT_LEFT = 20;
|
|
|
|
|
const auto TEXT_BASELINE = 20;
|
|
|
|
|
const auto TEXT_WIDTH = 50;
|
|
|
|
|
const auto BIN_HEIGHT = 30;
|
|
|
|
|
const auto BLOCK_WIDTH = 10;
|
|
|
|
|
double BLOCK_WIDTH = get_block_width();
|
|
|
|
|
|
|
|
|
|
const std::size_t MAX_ASTERISK = IMAGE_WIDTH - TEXT_WIDTH;
|
|
|
|
|
svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
|
|
|
|
|
double top = 0;
|
|
|
|
|