GladkyMS 8 месяцев назад
Родитель 7d912af179
Сommit 0437f9e1c3

@ -1,4 +1,7 @@
#pragma once
#include <vector>
#include<string>
void find_minmax(const std::vector<double>& numbers, double& min, double& max);
void find_minmax(const std::vector<double>& numbers, double& min, double& max);
std::string
bin_color(size_t bin, size_t mxbins);

@ -22,6 +22,9 @@ svg_text(double left, double baseline, std::string text) {
void svg_rect(double x, double y, double width, double height,std::string stroke = "black", std::string fill = "black") {
std::cout << "<rect x='"<<x<<"' y='"<<y<<"' width='"<<width<<"' height='"<<height<<"' stroke='"<<stroke<<"' fill='"<<fill<<"'/>";
}
//std::string bin_color(size_t bin, size_t mxbins) {
// return("#" + std::to_string((10 - floor((bin) * 9 / mxbins))) + std::to_string((10 - floor((bin) * 9 / mxbins))) + std::to_string((10 - floor((bin) * 9 / mxbins))));
//}
void show_histogram_svg(const std::vector<size_t>& bins, size_t bin_count) {
const auto IMAGE_WIDTH = 400;
@ -45,12 +48,10 @@ void show_histogram_svg(const std::vector<size_t>& bins, size_t bin_count) {
svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
double top = 0;
for (size_t bin : bins) {
int key = (10 - floor((bin) * 9 / mxbins));
std::string color = "#" +std::to_string(key)+ std::to_string(key)+ std::to_string(key);
/* std::string color = bin_color(bin,mxbins);*/
const double bin_width = BLOCK_WIDTH * bin*k;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,color,color);
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "#ffeeee");///color,color äëÿ ïåðñîíàëüíîãî âàðèàíòà
top += BIN_HEIGHT;
}
svg_end();

17
svg.h

@ -1,4 +1,19 @@
#pragma once
#include <vector>
#include<string>
void
svg_begin(double width, double height);
void show_histogram_svg(const std::vector<size_t>& bins, size_t bin_count);
void
svg_end();
void show_histogram_svg(const std::vector<size_t>& bins, size_t bin_count);
void
svg_text(double left, double baseline, std::string text);
//std::string
//bin_color(size_t bin, size_t mxbins);
void
svg_rect(double x, double y, double width, double height, std::string stroke , std::string fill );

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