|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include "svg.h"
|
|
|
|
|
using namespace std;
|
|
|
|
|
void
|
|
|
|
@ -29,13 +30,6 @@ cout << "<rect x='"<<x<<"' y='"<<y<<"' width='"<<width<<"' height='"<<height<<"'
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void color_find(double bin, int maxb, int& color){
|
|
|
|
|
color = (10 - (bin * 9) / maxb);
|
|
|
|
|
if (color < 0) { cout << "cant take color";
|
|
|
|
|
color = 9;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
|
|
|
|
|
@ -52,7 +46,7 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
|
double top = 0;
|
|
|
|
|
const size_t MAX_ASTERISK = IMAGE_WIDTH - TEXT_WIDTH;
|
|
|
|
|
int maxb = bins[0];
|
|
|
|
|
int color;
|
|
|
|
|
int color_value;
|
|
|
|
|
|
|
|
|
|
for (size_t j = 1; j < bins.size(); j++)
|
|
|
|
|
{
|
|
|
|
@ -65,7 +59,6 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
|
|
|
|
|
|
double bin_width;
|
|
|
|
|
|
|
|
|
|
color_find(bin, maxb, color);
|
|
|
|
|
|
|
|
|
|
if (maxb1 > MAX_ASTERISK)
|
|
|
|
|
{
|
|
|
|
@ -73,9 +66,12 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
|
}
|
|
|
|
|
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, "violet", to_string(color));
|
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
|
color_value = (10 - (bin * 9) / maxb);
|
|
|
|
|
string color = "#" + to_string(color_value) + to_string(color_value) + to_string(color_value);
|
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "violet", color);
|
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svg_end();
|
|
|
|
|