Code

only draw the new type of marker in the graph legend when called with --dynamic-label...
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Wed, 20 Jan 2010 19:47:04 +0000 (19:47 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Wed, 20 Jan 2010 19:47:04 +0000 (19:47 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@2005 a5681a0c-68f1-0310-ab6d-d61299d08faa

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

index 3b13f7f3f5ad6282e5bd8184095f4a4a860851bb..bac4d122f5355cb68899a4dc4c0d99582227148b 100644 (file)
@@ -72,8 +72,8 @@ Miscellaneous Changes
 * new graph option --border to set the 3d border width 
   by Bernhard Reutner-Fischer
 
-* draw different color swats depending on the type of line drawn in the
-  graph by Loïc Tortay
+* draw different color markers (enable with --dynamic-labels) depending on the
+  type of element in the graph by Loïc Tortay
 
 for more detail see the CHANGES file.
 
index 9f0dcf40a690a9a8ecd954c4a551e0d9927557af..e40b046bec1a809b4c1d1c3058e8a22e97749e49 100644 (file)
@@ -350,6 +350,10 @@ 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<--dynamic-labels>]
+
+Pick the shape of the color marker next to the label according to the element drawn on the graph.
+
 [B<--zoom> I<factor>]
 
 Zoom the graphics by the given amount. The factor must be E<gt> 0
index 6a3962690f1274a92bbac5a305a2e3d86aba4c94..258eb528dc3ea0e1af1d045a54ef17f7d557998a 100644 (file)
@@ -2733,7 +2733,8 @@ void grid_paint(
                 boxV = boxH;
                 /* shift the box up a bit */
                 Y0 -= boxV * 0.4;
-               if (im->gdes[i].gf == GF_HRULE) { /* [-] */ 
+
+        if (im->dynamic_labels && im->gdes[i].gf == GF_HRULE) { /* [-] */ 
                        cairo_save(im->cr);
                        cairo_new_path(im->cr);
                        cairo_set_line_width(im->cr, 1.0);
@@ -2742,7 +2743,7 @@ void grid_paint(
                                X0 + boxH, Y0 - boxV / 2,
                                1.0, im->gdes[i].col);
                        gfx_close_path(im);
-               } else if (im->gdes[i].gf == GF_VRULE) { /* [|] */
+               } else if (im->dynamic_labels && im->gdes[i].gf == GF_VRULE) { /* [|] */
                        cairo_save(im->cr);
                        cairo_new_path(im->cr);
                        cairo_set_line_width(im->cr, 1.0);
@@ -2751,7 +2752,7 @@ void grid_paint(
                                X0 + boxH / 2, Y0 - boxV,
                                1.0, im->gdes[i].col);
                        gfx_close_path(im);
-               } else if (im->gdes[i].gf == GF_LINE) { /* [/] */
+               } else if (im->dynamic_labels && im->gdes[i].gf == GF_LINE) { /* [/] */
                        cairo_save(im->cr);
                        cairo_new_path(im->cr);
                        cairo_set_line_width(im->cr, im->gdes[i].linewidth);
@@ -4009,6 +4010,7 @@ void rrd_graph_init(
     im->draw_x_grid = 1;
     im->draw_y_grid = 1;
     im->draw_3d_border = 2;
+    im->dynamic_labels = 0;
     im->extra_flags = 0;
     im->font_options = cairo_font_options_create();
     im->forceleftspace = 0;
@@ -4177,6 +4179,7 @@ void rrd_graph_options(
         { "legend-direction",   required_argument, 0, 1006},
         { "border",             required_argument, 0, 1007},
         { "grid-dash",          required_argument, 0, 1008},
+        { "dynamic-labels",     no_argument,       0, 1009},
         {  0, 0, 0, 0}
 };
 /* *INDENT-ON* */
@@ -4358,7 +4361,10 @@ void rrd_graph_options(
                 rrd_set_error("expected grid-dash format float:float");
                 return;
             }
-            break;            
+            break;   
+        case 1009: /* enable dynamic labels */
+            im->dynamic_labels = 1;
+            break;         
         case 1002: /* right y axis */
 
             if(sscanf(optarg,
index 7a85f340689ccd9173b9c30be2ab784a9d43fe79..8e28f63fec38544333b0e92e5b5596ab0d3116bb 100644 (file)
@@ -210,6 +210,7 @@ typedef struct image_desc_t {
     int       draw_x_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 */
+    unsigned int dynamic_labels; /* pick the label shape according to the line drawn */
     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 */