mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-14 03:23:29 +00:00
Fix graph updating for large (>512pix) graphs (sf.net #3253656)
apparently, this was actually a feature as someone made it deliberately act that way. However, I agree with the bug reporter that it is strange so I remove it.
This commit is contained in:
parent
6482283c03
commit
951cb1ac7e
@ -1580,12 +1580,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
cur_x + i + 1, by + h, cur_x + i + 1,
|
cur_x + i + 1, by + h, cur_x + i + 1,
|
||||||
round_to_int((double)by + h - current->graph[j] *
|
round_to_int((double)by + h - current->graph[j] *
|
||||||
(h - 1) / current->scale));
|
(h - 1) / current->scale));
|
||||||
if ((w - i) / ((float) (w - 2) /
|
|
||||||
(current->graph_width)) > j
|
|
||||||
&& j < MAX_GRAPH_DEPTH - 3) {
|
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
free_and_zero(tmpcolour);
|
free_and_zero(tmpcolour);
|
||||||
if (h > cur_y_add
|
if (h > cur_y_add
|
||||||
&& h > font_h) {
|
&& h > font_h) {
|
||||||
|
@ -392,13 +392,13 @@ static void graph_append(struct special_t *graph, double f, char showaslog)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* shift all the data by 1 */
|
/* shift all the data by 1 */
|
||||||
for (i = graph->graph_width - 1; i > 0; i--) {
|
for (i = graph->width - 1; i > 0; i--) {
|
||||||
graph->graph[i] = graph->graph[i - 1];
|
graph->graph[i] = graph->graph[i - 1];
|
||||||
}
|
}
|
||||||
graph->graph[0] = f; /* add new data */
|
graph->graph[0] = f; /* add new data */
|
||||||
|
|
||||||
if(graph->scaled) {
|
if(graph->scaled) {
|
||||||
graph->scale = *std::max_element(graph->graph + 0, graph->graph + graph->graph_width);
|
graph->scale = *std::max_element(graph->graph + 0, graph->graph + graph->width);
|
||||||
if(graph->scale < 1e-47) {
|
if(graph->scale < 1e-47) {
|
||||||
/* avoid NaN's when the graph is all-zero (e.g. before the first update)
|
/* avoid NaN's when the graph is all-zero (e.g. before the first update)
|
||||||
* there is nothing magical about 1e-47 here */
|
* there is nothing magical about 1e-47 here */
|
||||||
@ -422,14 +422,8 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
|||||||
|
|
||||||
s->width = g->width;
|
s->width = g->width;
|
||||||
if (s->graph == NULL) {
|
if (s->graph == NULL) {
|
||||||
if (s->width > 0 && s->width < MAX_GRAPH_DEPTH) {
|
s->graph = (double*)malloc(s->width * sizeof(double));
|
||||||
// subtract 2 for the box
|
memset(s->graph, 0, s->width * sizeof(double));
|
||||||
s->graph_width = s->width /* - 2 */;
|
|
||||||
} else {
|
|
||||||
s->graph_width = MAX_GRAPH_DEPTH - 2;
|
|
||||||
}
|
|
||||||
s->graph = (double*)malloc(s->graph_width * sizeof(double));
|
|
||||||
memset(s->graph, 0, s->graph_width * sizeof(double));
|
|
||||||
s->scale = 100;
|
s->scale = 100;
|
||||||
}
|
}
|
||||||
s->height = g->height;
|
s->height = g->height;
|
||||||
@ -445,9 +439,6 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
|||||||
s->show_scale = 1;
|
s->show_scale = 1;
|
||||||
}
|
}
|
||||||
s->tempgrad = g->tempgrad;
|
s->tempgrad = g->tempgrad;
|
||||||
/* if (s->width) {
|
|
||||||
s->graph_width = s->width - 2; // subtract 2 for rectangle around
|
|
||||||
} */
|
|
||||||
#ifdef MATH
|
#ifdef MATH
|
||||||
if (g->flags & SF_SHOWLOG) {
|
if (g->flags & SF_SHOWLOG) {
|
||||||
s->scale = log10(s->scale + 1);
|
s->scale = log10(s->scale + 1);
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
|
|
||||||
#define SPECIAL_CHAR '\x01'
|
#define SPECIAL_CHAR '\x01'
|
||||||
|
|
||||||
#define MAX_GRAPH_DEPTH 512
|
|
||||||
|
|
||||||
// don't use spaces in LOGGRAPH or NORMGRAPH if you change them
|
// don't use spaces in LOGGRAPH or NORMGRAPH if you change them
|
||||||
#define LOGGRAPH "-l"
|
#define LOGGRAPH "-l"
|
||||||
#define TEMPGRAD "-t"
|
#define TEMPGRAD "-t"
|
||||||
@ -67,7 +65,6 @@ struct special_t {
|
|||||||
double *graph;
|
double *graph;
|
||||||
double scale; /* maximum value */
|
double scale; /* maximum value */
|
||||||
short show_scale;
|
short show_scale;
|
||||||
int graph_width;
|
|
||||||
int scaled; /* auto adjust maximum */
|
int scaled; /* auto adjust maximum */
|
||||||
unsigned long first_colour; // for graph gradient
|
unsigned long first_colour; // for graph gradient
|
||||||
unsigned long last_colour;
|
unsigned long last_colour;
|
||||||
|
Loading…
Reference in New Issue
Block a user