1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +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:
Pavel Labath 2011-10-23 20:51:55 +02:00
parent 6482283c03
commit 951cb1ac7e
3 changed files with 5 additions and 21 deletions

View File

@ -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,
round_to_int((double)by + h - current->graph[j] *
(h - 1) / current->scale));
if ((w - i) / ((float) (w - 2) /
(current->graph_width)) > j
&& j < MAX_GRAPH_DEPTH - 3) {
j++;
}
}
free_and_zero(tmpcolour);
if (h > cur_y_add
&& h > font_h) {

View File

@ -392,13 +392,13 @@ static void graph_append(struct special_t *graph, double f, char showaslog)
}
/* 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[0] = f; /* add new data */
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) {
/* avoid NaN's when the graph is all-zero (e.g. before the first update)
* 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;
if (s->graph == NULL) {
if (s->width > 0 && s->width < MAX_GRAPH_DEPTH) {
// subtract 2 for the box
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->graph = (double*)malloc(s->width * sizeof(double));
memset(s->graph, 0, s->width * sizeof(double));
s->scale = 100;
}
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->tempgrad = g->tempgrad;
/* if (s->width) {
s->graph_width = s->width - 2; // subtract 2 for rectangle around
} */
#ifdef MATH
if (g->flags & SF_SHOWLOG) {
s->scale = log10(s->scale + 1);

View File

@ -34,8 +34,6 @@
#define SPECIAL_CHAR '\x01'
#define MAX_GRAPH_DEPTH 512
// don't use spaces in LOGGRAPH or NORMGRAPH if you change them
#define LOGGRAPH "-l"
#define TEMPGRAD "-t"
@ -67,7 +65,6 @@ struct special_t {
double *graph;
double scale; /* maximum value */
short show_scale;
int graph_width;
int scaled; /* auto adjust maximum */
unsigned long first_colour; // for graph gradient
unsigned long last_colour;