From 201f734bde7218d1aeb57497c46b2cce857e802f Mon Sep 17 00:00:00 2001 From: donutAnees Date: Sun, 28 Jul 2024 19:28:23 +0530 Subject: [PATCH] Fixed Down and Up Speed graph scaling --- src/specials.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/specials.cc b/src/specials.cc index 0a80cb379..77b3649b6 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -519,11 +519,21 @@ static void graph_append(struct special_node *graph, double f, char showaslog) { graph->graph[0] = f; /* add new data */ if (graph->scaled != 0) { - graph->scale = - *std::max_element(graph->graph + 0, graph->graph + graph->graph_width); + /* Get the location of the currentmax in the graph */ + double* currentmax = + std::max_element(graph->graph + 0, graph->graph + graph->graph_width); + graph->scale = *currentmax; if (graph->speedgraph) { - maxspeedval = graph->scale < maxspeedval ? maxspeedval : graph->scale; + if(maxspeedval < graph->scale){ + maxspeedval = graph->scale; + } graph->scale = maxspeedval; + /* If the currentmax is the maxspeedval and + * currentmax location is at the last position + * Then we reset our maxspeedval */ + if(*currentmax == maxspeedval && currentmax == (graph->graph + graph->width - 1)){ + maxspeedval = 1e-47; + } } if (graph->scale < 1e-47) { /* avoid NaN's when the graph is all-zero (e.g. before the first update)