From a339e7ea29488a6250368560a760410a1a6163b2 Mon Sep 17 00:00:00 2001 From: losinshi Date: Thu, 14 Sep 2006 20:17:13 +0000 Subject: [PATCH] scaling fixed git-svn-id: file:///home/jan/tmp/wetterstation/trunk@94 dd492736-c11a-0410-ad51-8c26713eaf7f --- cronjob/chart/chart.conf | 4 ++-- cronjob/chart/image_file/image_data.c | 4 ++-- cronjob/chart/image_file/image_draw.c | 13 +++++++------ cronjob/chart/image_file/testimage.conf | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cronjob/chart/chart.conf b/cronjob/chart/chart.conf index 13bb455..596ac8a 100644 --- a/cronjob/chart/chart.conf +++ b/cronjob/chart/chart.conf @@ -1,5 +1,5 @@ -fork yes -#fork no +#fork yes +fork no image_cfg_location image_file/ image_cfg testimage.conf diff --git a/cronjob/chart/image_file/image_data.c b/cronjob/chart/image_file/image_data.c index e93dc83..f3e4c15 100644 --- a/cronjob/chart/image_file/image_data.c +++ b/cronjob/chart/image_file/image_data.c @@ -162,12 +162,12 @@ int scale_y_coords(pix_list_ptr ptr, int c_height){ DEBUGOUT2(" Nullinie bei: %d\n", zero_line); +//printf("%f -- %f -- %d\n", range, pix_per_scale, zero_line); if ((real_max - real_min + 1) >= real_max){ return zero_line; } else { return -1; } - } /* Maximaler wert */ @@ -206,7 +206,7 @@ pix_list_ptr get_pix_list(int c_width){ table = get_type_table_by_id(conn, img_cfg.sens_id); } - snprintf(query, BUFFSIZE, "SELECT round(date_part('epoch', current_timestamp)) AS now, round(date_part('epoch', timestamp)) AS times, %s AS val FROM %s WHERE timestamp > (current_timestamp - INTERVAL '%d seconds') ORDER BY times ASC", img_cfg.table_field, table, img_cfg.show_interval ); + snprintf(query, BUFFSIZE, "SELECT round(date_part('epoch', current_timestamp)) AS now, round(date_part('epoch', timestamp)) AS times, %s AS val FROM %s WHERE sens_id=%d AND timestamp > (current_timestamp - INTERVAL '%d seconds') ORDER BY times ASC", img_cfg.table_field, table, img_cfg.sens_id, img_cfg.show_interval ); res = pg_check_exec(conn, query); diff --git a/cronjob/chart/image_file/image_draw.c b/cronjob/chart/image_file/image_draw.c index ac9a3e2..ee0ab9d 100644 --- a/cronjob/chart/image_file/image_draw.c +++ b/cronjob/chart/image_file/image_draw.c @@ -61,9 +61,9 @@ static gdImagePtr draw_image(gdImagePtr img){ int offset_x_left = 60; int offset_y_top = 5; int offset_x_right = 20; - int offset_y_bottom = 20; + int offset_y_bottom = 80; int dia_width = img_cfg.width - offset_x_left - offset_x_right; - int dia_height = img_cfg.height - offset_y_top - offset_y_bottom; + int dia_height = 0; int zero_line = 0; int dia_y_padding = 10; int brect[8]; @@ -85,12 +85,13 @@ static gdImagePtr draw_image(gdImagePtr img){ gdImageStringTTF(img, &brect[0], headline_c, IMG_FONT, 16, 0, 10, offset_y_top + head_d.to_base, img_cfg.headline); offset_y_top = (offset_y_top * 2) + head_d.height; + + + dia_height = img_cfg.height - offset_y_top - offset_y_bottom; + /* Werte holen */ pix_list = get_pix_list(dia_width); - - - /* Diagramhintergrund */ gdImageFilledRectangle(img, offset_x_left, offset_y_top, img_cfg.width - offset_x_right, img_cfg.height - offset_y_bottom, dia_bg_c); @@ -117,7 +118,7 @@ static gdImagePtr draw_image(gdImagePtr img){ /* Werte Zeichnen */ for (; pix_list->next; pix_list = pix_list->next){ - gdImageLine(img, (offset_x_left + pix_list->x_pix_coord), (zero_line + offset_y_top + pix_list->y_pix_coord), (offset_x_left + pix_list->next->x_pix_coord), (zero_line + offset_y_top + pix_list->next->y_pix_coord), val_line_c); + gdImageLine(img, (offset_x_left + pix_list->x_pix_coord), (offset_y_top + pix_list->y_pix_coord), (offset_x_left + pix_list->next->x_pix_coord), (offset_y_top + pix_list->next->y_pix_coord), val_line_c); } gdImageRectangle(img, offset_x_left, offset_y_top, img_cfg.width - offset_x_right, img_cfg.height - offset_y_bottom, dia_border_c); diff --git a/cronjob/chart/image_file/testimage.conf b/cronjob/chart/image_file/testimage.conf index 7213e4d..66dc3fe 100644 --- a/cronjob/chart/image_file/testimage.conf +++ b/cronjob/chart/image_file/testimage.conf @@ -8,7 +8,7 @@ show_interval 10d label_interval 1d label_sum no width 800 -height 250 +height 400 sensor_id 1 value_koeffizient 0.1