The attached patch allows to
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Wed, 19 Aug 2009 15:24:11 +0000 (15:24 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Wed, 19 Aug 2009 15:24:11 +0000 (15:24 +0000)
$ 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/program@1898 a5681a0c-68f1-0310-ab6d-d61299d08faa

NEWS
doc/rrdgraph.pod
src/rrd_graph.c
src/rrd_graph.h
src/rrd_tool.c

diff --git a/NEWS b/NEWS
index ba0d8ad..d5a4ad2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -64,4 +64,8 @@ Miscellaneous Changes
 * allow the HW smoothing window size to be set to 0 with rrdtool tune
   by sylvain luiset
 
 * 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.
 for more detail see the CHANGES file.
index 57359ac..dc8081f 100644 (file)
@@ -336,6 +336,12 @@ multiple defaults.
 
 A green arrow is made by: C<--color ARROW#00FF00>
 
 
 A green arrow is made by: C<--color ARROW#00FF00>
 
+[B<--border> I<width>]]
+
+Width in pixels for the 3d border drawn around the image. Default 2, 0
+disables the border. See C<SHADEA> and C<SHADEB> above for setting the border
+color.
+
 [B<--zoom> I<factor>]
 
 Zoom the graphics by the given amount. The factor must be E<gt> 0
 [B<--zoom> I<factor>]
 
 Zoom the graphics by the given amount. The factor must be E<gt> 0
index 323fec6..002137f 100644 (file)
@@ -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;
         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;
 
     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) {
     if (im->draw_x_grid == 1)
         vertical_grid(im);
     if (im->draw_y_grid == 1) {
@@ -2704,7 +2707,8 @@ void grid_paint(
     }
 
     /* graph labels */
     }
 
     /* 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;
         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->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;
     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'},
         { "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'},
         { "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;
                 return;
             }
             break;
+        case 1007:
+            im->draw_3d_border = atoi(optarg);
+            break;
         case 1002: /* right y axis */
 
             if(sscanf(optarg,
         case 1002: /* right y axis */
 
             if(sscanf(optarg,
index 0593d4a..d3de4cf 100644 (file)
@@ -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 */
     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 */
     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 */
index 8f23326..1f7e6b0 100644 (file)
@@ -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[-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 =
            "\t\t[-W|--watermark string]\n"
            "\t\t[DEF:vname=rrd:ds-name:CF]\n");
     const char *help_graph3 =