From: oetiker Date: Wed, 19 Aug 2009 15:24:11 +0000 (+0000) Subject: The attached patch allows to X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7ad023c954e155a202c4c3a55d98428101070b7b;p=rrdtool-all.git The attached patch allows to $ rrdtool graph --border=0 to disable the 3d border around the image. -- Bernhard Reutner-Fischer rep.dot.nop gmail.com git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1898 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/NEWS b/program/NEWS index ba0d8ad9..d5a4ad2e 100644 --- a/program/NEWS +++ b/program/NEWS @@ -64,4 +64,8 @@ Miscellaneous Changes * allow the HW smoothing window size to be set to 0 with rrdtool tune by sylvain luiset +* new graph option --border to set the 3d border width + by Bernhard Reutner-Fischer + + for more detail see the CHANGES file. diff --git a/program/doc/rrdgraph.pod b/program/doc/rrdgraph.pod index 57359ac6..dc8081f2 100644 --- a/program/doc/rrdgraph.pod +++ b/program/doc/rrdgraph.pod @@ -336,6 +336,12 @@ multiple defaults. A green arrow is made by: C<--color ARROW#00FF00> +[B<--border> I]] + +Width in pixels for the 3d border drawn around the image. Default 2, 0 +disables the border. See C and C above for setting the border +color. + [B<--zoom> I] Zoom the graphics by the given amount. The factor must be E 0 diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 323fec6d..002137fa 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -1685,7 +1685,7 @@ int leg_place( } - if (!(im->extra_flags & NOLEGEND) & !(im->extra_flags & ONLY_GRAPH)) { + if (!(im->extra_flags & NOLEGEND) && !(im->extra_flags & ONLY_GRAPH)) { if ((legspace = (int*)malloc(im->gdes_c * sizeof(int))) == NULL) { rrd_set_error("malloc for legspace"); return -1; @@ -2606,20 +2606,23 @@ void grid_paint( double X0, Y0; /* points for filled graph and more */ struct gfx_color_t water_color; - /* draw 3d border */ - gfx_new_area(im, 0, im->yimg, - 2, im->yimg - 2, 2, 2, im->graph_col[GRC_SHADEA]); - gfx_add_point(im, im->ximg - 2, 2); - gfx_add_point(im, im->ximg, 0); - gfx_add_point(im, 0, 0); - gfx_close_path(im); - gfx_new_area(im, 2, im->yimg - 2, - im->ximg - 2, - im->yimg - 2, im->ximg - 2, 2, im->graph_col[GRC_SHADEB]); - gfx_add_point(im, im->ximg, 0); - gfx_add_point(im, im->ximg, im->yimg); - gfx_add_point(im, 0, im->yimg); - gfx_close_path(im); + if (im->draw_3d_border > 0) { + /* draw 3d border */ + i = im->draw_3d_border; + gfx_new_area(im, 0, im->yimg, + i, im->yimg - i, i, i, im->graph_col[GRC_SHADEA]); + gfx_add_point(im, im->ximg - i, i); + gfx_add_point(im, im->ximg, 0); + gfx_add_point(im, 0, 0); + gfx_close_path(im); + gfx_new_area(im, i, im->yimg - i, + im->ximg - i, + im->yimg - i, im->ximg - i, i, im->graph_col[GRC_SHADEB]); + gfx_add_point(im, im->ximg, 0); + gfx_add_point(im, im->ximg, im->yimg); + gfx_add_point(im, 0, im->yimg); + gfx_close_path(im); + } if (im->draw_x_grid == 1) vertical_grid(im); if (im->draw_y_grid == 1) { @@ -2704,7 +2707,8 @@ void grid_paint( } /* graph labels */ - if (!(im->extra_flags & NOLEGEND) & !(im->extra_flags & ONLY_GRAPH)) { +/* didn't look closely, nor think.. but did you mean ') && !(' below? */ + if (!(im->extra_flags & NOLEGEND) && !(im->extra_flags & ONLY_GRAPH)) { for (i = 0; i < im->gdes_c; i++) { if (im->gdes[i].legend[0] == '\0') continue; @@ -3990,6 +3994,7 @@ void rrd_graph_init( im->daemon_addr = NULL; im->draw_x_grid = 1; im->draw_y_grid = 1; + im->draw_3d_border = 2; im->extra_flags = 0; im->font_options = cairo_font_options_create(); im->forceleftspace = 0; @@ -4123,6 +4128,7 @@ void rrd_graph_options( { "base", required_argument, 0, 'b'}, { "logarithmic", no_argument, 0, 'o'}, { "color", required_argument, 0, 'c'}, + { "border", required_argument, 0, 1007}, { "font", required_argument, 0, 'n'}, { "title", required_argument, 0, 't'}, { "imginfo", required_argument, 0, 'f'}, @@ -4335,6 +4341,9 @@ void rrd_graph_options( return; } break; + case 1007: + im->draw_3d_border = atoi(optarg); + break; case 1002: /* right y axis */ if(sscanf(optarg, diff --git a/program/src/rrd_graph.h b/program/src/rrd_graph.h index 0593d4a9..d3de4cf0 100644 --- a/program/src/rrd_graph.h +++ b/program/src/rrd_graph.h @@ -203,7 +203,8 @@ typedef struct image_desc_t { char title[210]; /* title for graph */ char watermark[110]; /* watermark for graph */ int draw_x_grid; /* no x-grid at all */ - int draw_y_grid; /* no x-grid at all */ + int draw_y_grid; /* no y-grid at all */ + unsigned int draw_3d_border; /* size of border in pixels, 0 for off */ double grid_dash_on, grid_dash_off; xlab_t xlab_user; /* user defined labeling for xaxis */ char xlab_form[210]; /* format for the label on the xaxis */ diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c index 8f233268..1f7e6b09 100644 --- a/program/src/rrd_tool.c +++ b/program/src/rrd_tool.c @@ -161,7 +161,9 @@ void PrintUsage( "\t\t[-S|--step seconds]\n" "\t\t[-f|--imginfo printfstr]\n" "\t\t[-a|--imgformat PNG]\n" - "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n" + "\t\t[-c|--color COLORTAG#rrggbb[aa]]\n" + "\t\t[-d|--border width\n" + "\t\t[-t|--title string]\n" "\t\t[-W|--watermark string]\n" "\t\t[DEF:vname=rrd:ds-name:CF]\n"); const char *help_graph3 =