+ stimes = g_hash_table_lookup(times, s->id);
+
+ color = config_get_sensor_color(s->id);
+
+ cairo_set_source_rgb(cr,
+ color->red,
+ color->green,
+ color->blue);
+ gdk_rgba_free(color);
+
+ /* search the index of the first measure used as a start point
+ * of a Bezier curve. The start and end points of the Bezier
+ * curves must be preserved to ensure the same overall shape
+ * of the graph.
+ */
+ i = 0;
+ if (stimes) {
+ while (i < s->values_max_length) {
+ t = s->measures[i].time.tv_sec;
+ v = s->measures[i].value;
+
+ found = 0;
+ if (v != UNKNOWN_DBL_VALUE && t) {
+ k = 0;
+ while (stimes[k]) {
+ if (t == stimes[k]) {
+ found = 1;
+ break;
+ }
+ k++;
+ }
+ }
+
+ if (found)
+ break;
+
+ i++;
+ }
+ }
+
+ stimes = malloc((s->values_max_length + 1) * sizeof(time_t));
+ memset(stimes, 0, (s->values_max_length + 1) * sizeof(time_t));
+ g_hash_table_insert(times, strdup(s->id), stimes);
+
+ if (i == s->values_max_length)
+ i = 0;
+
+ k = 0;
+ dt = et - bt;
+ while (i < s->values_max_length) {
+ j = 0;
+ t = 0;
+ while (i < s->values_max_length && j < 4) {
+ t = s->measures[i].time.tv_sec;
+ v = s->measures[i].value;
+
+ if (v == UNKNOWN_DBL_VALUE || !t) {
+ i++;
+ continue;
+ }
+
+ vdt = t - bt;
+
+ x[0 + j] = ((double)vdt * info->g_width)
+ / dt + info->g_xoff;
+ y[0 + j] = compute_y(v,
+ min,
+ max,
+ info->g_height,
+ info->g_yoff);
+
+ if (j == 0)
+ t0 = t;
+
+ i++;
+ j++;
+ }
+
+ if (j == 4) {
+ cairo_move_to(cr, x[0], y[0]);
+ cairo_curve_to(cr, x[1], y[1], x[2], y[3], x[3], y[3]);
+ stimes[k++] = t0;
+ i--;
+ }
+ }
+
+ cairo_stroke(cr);