diff --git a/main.cpp b/main.cpp
index d3676af..19c5a82 100644
--- a/main.cpp
+++ b/main.cpp
@@ -26,7 +26,7 @@ input_data() {
cin >> in.numbers[i];
}
- cout << "Enter number of bins";
+ cerr << "Enter number of bins";
cin >> in.bin_count;
return in;
}
diff --git a/project3.cbp b/project3.cbp
index 2270934..57c9634 100644
--- a/project3.cbp
+++ b/project3.cbp
@@ -40,6 +40,10 @@
+
+
+
+
diff --git a/project3.depend b/project3.depend
index a0f7a3f..f777c7f 100644
--- a/project3.depend
+++ b/project3.depend
@@ -1,5 +1,5 @@
# depslib dependency file v1.0
-1682281180 source:c:\users\hp\desktop\lab-03\project3\main.cpp
+1682333921 source:c:\users\hp\desktop\lab-03\project3\main.cpp
@@ -33,14 +33,13 @@
1682275464 c:\users\hp\desktop\lab-03\project3\histogram_internal.h
-1682280773 source:c:\users\hp\desktop\lab-03\project3\svg.cpp
+1682282112 source:c:\users\hp\desktop\lab-03\project3\svg.cpp
"svg.h"
-
1682278136 c:\users\hp\desktop\lab-03\project3\svg.h
diff --git a/project3.layout b/project3.layout
index 5bf559e..367d5da 100644
--- a/project3.layout
+++ b/project3.layout
@@ -2,24 +2,44 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svg.cpp b/svg.cpp
index c590e2d..f81e0c2 100644
--- a/svg.cpp
+++ b/svg.cpp
@@ -26,10 +26,31 @@ svg_text(double left, double baseline, string text) {
cout << "" << text << "";
}
+void svg_rect(double x, double y, double width, double height, string colour = "black", string fill = "black"){
+ cout << "";
+}
+
void
show_histogram_svg(const vector& 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 top = 0;
+ double max_count = bins[0];
+ for (size_t i = 0; i < bins.size(); i++) {
+ if (bins[i] > max_count)
+ max_count = bins[i];
+ }
svg_begin(400, 300);
- svg_text(20, 20, to_string(bins[0]));
+ for (size_t bin : bins) {
+ const double bin_width = (IMAGE_WIDTH - TEXT_WIDTH)*(bin/max_count);
+ svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
+ svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#FF00FF");
+ top += BIN_HEIGHT;
+ }
svg_end();
}
-
diff --git a/unitest.cbp b/unitest.cbp
index b58cac2..b0fa675 100644
--- a/unitest.cbp
+++ b/unitest.cbp
@@ -31,6 +31,10 @@
+
+
+
+