diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 546bf6e..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-/bin
-/obj
-*.layout
-*.depend
\ No newline at end of file
diff --git a/Lab01.cbp b/Lab01.cbp
deleted file mode 100644
index aff3a35..0000000
--- a/Lab01.cbp
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/README.md b/README.md
deleted file mode 100644
index e69de29..0000000
diff --git a/doctest.h b/doctest.h
index ffbd34a..5c754cd 100644
--- a/doctest.h
+++ b/doctest.h
@@ -7082,7 +7082,7 @@ namespace detail {
#ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4007) // 'function' : must be 'attribute' - see issue #182
-
+int main(int argc, char** argv) { return doctest::Context(argc, argv).run(); }
DOCTEST_MSVC_SUPPRESS_WARNING_POP
#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
diff --git a/main.cpp b/main.cpp
index 8b6cb7c..5677ea7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -36,10 +36,3 @@ main()
show_histogram_svg(bins);
return 0;
}
-
-
-
-
-
-
-
diff --git a/svg.cpp b/svg.cpp
index 3669a33..591f69b 100644
--- a/svg.cpp
+++ b/svg.cpp
@@ -1,66 +1,66 @@
#include
+#include
#include "svg.h"
+const auto IMAGE_WIDTH = 400;
+const auto IMAGE_HEIGHT = 310;
+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;
+
void
-svg_begin(double width, double height) {
+svg_begin(double width, double height)
+{
std::cout << "\n";
std::cout << "\n";
}
void
-svg_text(double left, double baseline, std::string text) {
- std::cout << " " << text << " ";
+svg_text(double left, double baseline, std::string text)
+{
+ std::cout << "\n";
+ std::cout << " " << text << " ";
}
-void svg_rect(double x, double y, double width, double height){
- std::cout << "";
+void svg_rect(double x, double y, double width, double height)
+{
+ std::cout << "";
+ std::cout << "\n";
}
-void
-show_histogram_svg(const std::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;
- const std::size_t MAX_ASTERISK = IMAGE_WIDTH - TEXT_WIDTH;
- svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
- double top = 0;
-
- std::size_t maxbin=bins[0];
- for (std::size_t i=0; i < bins.size(); i++){
- if (maxbin < bins[i]){
- maxbin=bins[i];
+ void show_histogram_svg(const std::vector& bins) {
+ double max = 0, scale = 1;
+ int maxlen = IMAGE_WIDTH - TEXT_WIDTH;
+ for (auto el: bins)
+ {
+ if (max < el)
+ {
+ max = el;
+ }
}
- }
-
- if (maxbin<=76){
- for (std::size_t i=0; i < bins.size(); i++) {
- double bin_width = BLOCK_WIDTH * bins[i];
- svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
- svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
- top += BIN_HEIGHT;
- }
- svg_end();
- } else {
- for (std::size_t i=0; i < bins.size(); i++) {
- double bin_width= MAX_ASTERISK * (static_cast(bins[i]) / maxbin);
- svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
- svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
+ svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
+ double top = 5;
+ scale = max * BLOCK_WIDTH / maxlen;
+ for (size_t bin : bins)
+ {
+ const double bin_width = BLOCK_WIDTH * bin;
+ svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
+ svg_rect(TEXT_WIDTH, top, bin_width / scale, BIN_HEIGHT);
top += BIN_HEIGHT;
}
- svg_end();
+ svg_end(top);
}
-}
diff --git a/unittest.cbp b/unittest.cbp
index 379d0a2..534f497 100644
--- a/unittest.cbp
+++ b/unittest.cbp
@@ -31,10 +31,11 @@
-
-
+
+
+