aboutsummaryrefslogtreecommitdiff
path: root/src/gtk-valuegraph.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtk-valuegraph.c')
-rw-r--r--src/gtk-valuegraph.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gtk-valuegraph.c b/src/gtk-valuegraph.c
index b5d2bf1..555cec9 100644
--- a/src/gtk-valuegraph.c
+++ b/src/gtk-valuegraph.c
@@ -11,12 +11,14 @@
#include <gtk/gtk.h>
#include <math.h>
+#include <stdlib.h>
#include "gtk-valuegraph.h"
static GtkObjectClass *parent_class = NULL;
static void gtk_value_graph_destroy(GtkObject *gtk_value_graph) {
+ free(GTK_VALUE_GRAPH(gtk_value_graph)->data);
parent_class->destroy(gtk_value_graph);
}
@@ -161,8 +163,17 @@ static gint gtk_value_graph_draw(GtkWidget *graph, GdkEventExpose *event, gpoint
cairo_move_to(cr, bw_left, height-bw_bottom-1-scale*(vg->data[0]-vg->ymin));
for ( i=1; i<vg->n; i++ ) {
- cairo_line_to(cr, bw_left+((double)i/vg->xmax)*(width-bw_left-bw_right), height-bw_bottom-1-scale*(vg->data[i]-vg->ymin));
-
+ int p;
+
+ p = i-1;
+ if ( p < 1 ) p = 1;
+
+ if ( !isnan(vg->data[i]) && !isnan(vg->data[p]) ) {
+ cairo_line_to(cr, bw_left+((double)i/vg->xmax)*(width-bw_left-bw_right), height-bw_bottom-1-scale*(vg->data[i]-vg->ymin));
+ } else {
+ cairo_move_to(cr, bw_left+((double)i/vg->xmax)*(width-bw_left-bw_right), height-bw_bottom-1-scale*(vg->data[i]-vg->ymin));
+ }
+
}
cairo_set_line_width(cr, 0.5);
cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);