From: oetiker Date: Wed, 20 Jan 2010 19:47:04 +0000 (+0000) Subject: only draw the new type of marker in the graph legend when called with --dynamic-label... X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=commitdiff_plain;h=c502ca0c6ed02387134193d215f6af0b3e29afe1;ds=sidebyside only draw the new type of marker in the graph legend when called with --dynamic-labels -- tobi git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@2005 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/NEWS b/NEWS index 3b13f7f..bac4d12 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/doc/rrdgraph.pod b/doc/rrdgraph.pod index 9f0dcf4..e40b046 100644 --- a/doc/rrdgraph.pod +++ b/doc/rrdgraph.pod @@ -350,6 +350,10 @@ 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<--dynamic-labels>] + +Pick the shape of the color marker next to the label according to the element drawn on the graph. + [B<--zoom> I] Zoom the graphics by the given amount. The factor must be E 0 diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 6a39626..258eb52 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -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, diff --git a/src/rrd_graph.h b/src/rrd_graph.h index 7a85f34..8e28f63 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -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 */