diff --git a/lab3.cbp b/lab3.cbp
index e00a5e7..8047f4d 100644
--- a/lab3.cbp
+++ b/lab3.cbp
@@ -35,6 +35,8 @@
+
+
diff --git a/lab3.depend b/lab3.depend
index 1c68264..134a14f 100644
--- a/lab3.depend
+++ b/lab3.depend
@@ -1,5 +1,5 @@
# depslib dependency file v1.0
-1686350213 source:c:\users\kostello\desktop\lubs\lab03.2\main.cpp
+1686359317 source:c:\users\kostello\desktop\lubs\lab03.2\main.cpp
"histogram.h"
"text.h"
@@ -19,11 +19,11 @@
-1686349467 c:\users\kostello\desktop\lubs\lab03.2\svg.h
+1686357236 c:\users\kostello\desktop\lubs\lab03.2\svg.h
-1686349791 source:c:\users\kostello\desktop\lubs\lab03.2\svg.cpp
+1686357236 source:c:\users\kostello\desktop\lubs\lab03.2\svg.cpp
"svg.h"
diff --git a/main.cpp b/main.cpp
index 4d721e6..9fe1139 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,5 +1,4 @@
-#include
#include "histogram.h"
#include "text.h"
#include "svg.h"
@@ -10,7 +9,7 @@ using namespace std;
struct Input {
vector numbers;
size_t bin_count{};
- // vector colour;
+ vector colour;
};
Input
@@ -29,11 +28,11 @@ for (size_t i = 0; i < number_count; i++) {
cin >> in.bin_count;
-/*in.numbers.resize(in.bin_count);
+in.colour.resize(in.bin_count+1);
for (size_t i = 0; i < in.bin_count; i++) {
- cin >> in.colour[i];*/
-
+ cin >> in.colour[i];
+}
return in;
}
@@ -43,7 +42,7 @@ int main()
{
auto in = input_data();
auto bins = make_histogram(in.numbers, in.bin_count);
- show_histogram_svg(bins);
+ show_histogram_svg(bins, in.colour);
return 0;
}
diff --git a/svg.cpp b/svg.cpp
index c619323..df170aa 100644
--- a/svg.cpp
+++ b/svg.cpp
@@ -30,7 +30,7 @@ cout << "& bins) {
+show_histogram_svg(const vector& bins, const vector& colour) {
const auto IMAGE_WIDTH = 400;
const auto IMAGE_HEIGHT = 300;
@@ -42,10 +42,10 @@ show_histogram_svg(const vector& bins) {
svg_begin(400, 300);
double top = 0;
- for (size_t bin : bins) {
- const double bin_width = BLOCK_WIDTH * bin;
- svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
- svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "#ffeeee");
+ for (size_t i=0; i< bins.size(); i++) {
+ const double bin_width = BLOCK_WIDTH * bins[i];
+ svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i]));
+ svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", colour[i]);
top += BIN_HEIGHT;
}
svg_end();
diff --git a/svg.h b/svg.h
index 06048d0..7dc179c 100644
--- a/svg.h
+++ b/svg.h
@@ -3,7 +3,8 @@
#include
#include
+#include
-void show_histogram_svg(const std::vector& bins);
+void show_histogram_svg(const std::vector& bins, const std::vector& colour);
#endif // SVG_H_INCLUDED