Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review the autorescale_x/autorescale_y logic in GraphVisual #268

Closed
sebjameswml opened this issue Oct 16, 2024 · 1 comment · Fixed by #269
Closed

Review the autorescale_x/autorescale_y logic in GraphVisual #268

sebjameswml opened this issue Oct 16, 2024 · 1 comment · Fixed by #269

Comments

@sebjameswml
Copy link
Collaborator

I don't like the repeated calls to setlimits in the for loops. I'd prefer one call after the loop. There's probably a better way to find min/max than UpdateMinMax. Probably use of morph::range.

@sebjameswml
Copy link
Collaborator Author

e.g.:

diff --git a/morph/GraphVisual.h b/morph/GraphVisual.h
index 63d6f02..af11e2f 100644
--- a/morph/GraphVisual.h
+++ b/morph/GraphVisual.h
@@ -197,11 +197,10 @@ namespace morph {
                 if (this->auto_rescale_y && this->auto_rescale_fit) {
                   this->ord1_scale.reset();
                   this->ord2_scale.reset();
-                  Flt min_y = _data[0], max_y = _data[0];
-                  for (auto y_val : _data) {
-                    this->UpdateMinMax(y_val, min_y, max_y, min_y, max_y);
-                  }
-                  this->setlimits_y(min_y, max_y);
+                  morph::range<Flt> datarange;
+                  datarange.search_init();
+                  for (auto y_val : _data) { datarange.update (y_val); }
+                  this->setlimits_y (datarange.min, datarange.max);
                 } else if (this->auto_rescale_y) {
                     for (auto y_val : _data) {
                         if (!(y_val >= this->datamin_y && y_val <= this->datamax_y)) {

@sebjameswml sebjameswml linked a pull request Oct 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant