1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-22 18:48:14 +00:00

Added getters for graphs ymin and ymax (#8112)

Co-authored-by: guillempages <guillempages@users.noreply.github.com>
This commit is contained in:
Mikkel Jeppesen 2025-03-15 06:55:20 +01:00 committed by GitHub
parent 7679c716b3
commit fa25cebed5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -132,6 +132,10 @@ void Graph::draw(Display *buff, uint16_t x_offset, uint16_t y_offset, Color colo
yrange = ymax - ymin;
}
// Store graph limts
this->graph_limit_max_ = ymax;
this->graph_limit_min_ = ymin;
/// Draw grid
if (!std::isnan(this->gridspacing_y_)) {
for (int y = yn; y <= ym; y++) {

View File

@ -161,11 +161,15 @@ class Graph : public Component {
uint32_t get_duration() { return duration_; }
uint32_t get_width() { return width_; }
uint32_t get_height() { return height_; }
float get_graph_limit_min() { return graph_limit_min_; }
float get_graph_limit_max() { return graph_limit_max_; }
protected:
uint32_t duration_; /// in seconds
uint32_t width_; /// in pixels
uint32_t height_; /// in pixels
float graph_limit_min_{NAN};
float graph_limit_max_{NAN};
float min_value_{NAN};
float max_value_{NAN};
float min_range_{1.0};