Closed sebjameswml closed 1 week ago
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)) {
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.