diff --git a/lab01.cbp b/lab01.cbp
index 76beffa..6624bca 100644
--- a/lab01.cbp
+++ b/lab01.cbp
@@ -36,7 +36,14 @@
+
+
+
+
+
+
+
diff --git a/main.cpp b/main.cpp
index 82335ac..72dcc4b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -2,6 +2,7 @@
#include
#include "histogram.h"
#include "text.h"
+#include "svg.h"
using namespace std;
@@ -36,6 +37,7 @@ int main()
{
auto in = input_data();
auto bins = make_histogram(in.numbers, in.bin_count);
- show_histogram_text(bins, in.bin_count);
+ //show_histogram_text(bins, in.bin_count);
+ show_histogram_svg(bins);
return 0;
}
diff --git a/svg.cpp b/svg.cpp
new file mode 100644
index 0000000..16670af
--- /dev/null
+++ b/svg.cpp
@@ -0,0 +1,74 @@
+#include "svg.h"
+
+using namespace std;
+
+void svg_begin(double width, double height)
+{
+ cout << "\n"
+ << "\n";
+}
+void show_histogram_svg(const vector& bins)
+{
+ const double IMAGE_WIDTH = 400;
+ const double IMAGE_HEIGHT = 300;
+ const double TEXT_LEFT = 20;
+ const double TEXT_BASELINE = 20;
+ const double TEXT_WIDTH = 50;
+ const double BIN_HEIGHT = 30;
+ const double BLOCK_WIDTH = 10;
+
+ svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
+
+ size_t max_count = 0;
+ for (size_t count : bins)
+ {
+ if (count > max_count)
+ {
+ max_count = count;
+ }
+ }
+
+ double max_width = IMAGE_WIDTH - TEXT_WIDTH;
+ double top = 0;
+ for (size_t count : bins)
+ {
+ double bin_width;
+ if (max_count > 0)
+ {
+ bin_width = static_cast(count) / max_count * max_width;
+ }
+ else
+ {
+ bin_width = 0.0;
+ }
+
+ svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(count));
+ svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#aaffaa");
+ top += BIN_HEIGHT;
+ }
+ svg_end();
+}
diff --git a/svg.h b/svg.h
new file mode 100644
index 0000000..23ba89b
--- /dev/null
+++ b/svg.h
@@ -0,0 +1,10 @@
+#ifndef SVG_H_INCLUDED
+#define SVG_H_INCLUDED
+
+#include
+#include
+#include
+
+void show_histogram_svg(const std::vector& bins);
+
+#endif // SVG_H_INCLUDED
diff --git a/unittest.cbp b/unittest.cbp
index 7f9621b..534f497 100644
--- a/unittest.cbp
+++ b/unittest.cbp
@@ -31,6 +31,9 @@
+
+
+