X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_graph.c;h=bd7e3c341a2dd3f8934146736f14c3914363bcd0;hp=7b9f64844408de5104ec9c7183073f703fdef34e;hb=8be74deb0aa2a4ee0898642ba9df8a3e5f3f97d6;hpb=ce30e9e1379022835687aa08b7712e27372e05ec diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 7b9f648..bd7e3c3 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.4.1 Copyright by Tobi Oetiker, 1997-2009 + * RRDtool 1.4.2 Copyright by Tobi Oetiker, 1997-2009 **************************************************************************** * rrd__graph.c produce graphs from data in rrdfiles ****************************************************************************/ @@ -29,6 +29,10 @@ #include +#ifdef HAVE_LANGINFO_H +#include +#endif + #include "rrd_graph.h" #include "rrd_client.h" @@ -1248,7 +1252,7 @@ int data_proc( } else if (((long int) gr_time >= (long int) im->gdes[vidx].start) - && ((long int) gr_time <= + && ((long int) gr_time < (long int) im->gdes[vidx].end)) { value = im->gdes[vidx].data[(unsigned long) floor((double) @@ -1356,6 +1360,17 @@ int data_proc( } +static int find_first_weekday(void){ + static int first_weekday = -1; + if (first_weekday == -1){ +#if defined(HAVE_NL_LANGINFO) + first_weekday = nl_langinfo(_NL_TIME_FIRST_WEEKDAY)[0] - 1; +#else + first_weekday = 1; +#endif + } + return first_weekday; +} /* identify the point where the first gridline, label ... gets placed */ @@ -1397,10 +1412,10 @@ time_t find_first_time( tm. tm_sec = 0; tm. tm_min = 0; tm. tm_hour = 0; - tm. tm_mday -= tm.tm_wday - 1; /* -1 because we want the monday */ + tm. tm_mday -= tm.tm_wday - find_first_weekday(); - if (tm.tm_wday == 0) - tm. tm_mday -= 7; /* we want the *previous* monday */ + if (tm.tm_wday == 0 && find_first_weekday() > 0) + tm. tm_mday -= 7; /* we want the *previous* week */ break; case TMT_MONTH: @@ -1730,6 +1745,7 @@ int leg_place( prt_fctn != 'r' && prt_fctn != 'j' && prt_fctn != 'c' && + prt_fctn != 'u' && prt_fctn != 's' && prt_fctn != '\0' && prt_fctn != 'g') { free(legspace); rrd_set_error @@ -1818,7 +1834,7 @@ int leg_place( if (prt_fctn == 'c') leg_x = (double)(legendwidth - fill) / 2.0; if (prt_fctn == 'r') - leg_x = legendwidth - fill - border; + leg_x = legendwidth - fill + border; for (ii = mark; ii <= i; ii++) { if (im->gdes[ii].legend[0] == '\0') continue; /* skip empty legends */ @@ -1839,6 +1855,8 @@ int leg_place( leg_y += im->text_prop[TEXT_PROP_LEGEND].size * 1.8; if (prt_fctn == 's') leg_y -= im->text_prop[TEXT_PROP_LEGEND].size; + if (prt_fctn == 'u') + leg_y -= im->text_prop[TEXT_PROP_LEGEND].size *1.8; if(calc_width && (fill > legendwidth)){ legendwidth = fill; @@ -2733,7 +2751,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 +2761,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 +2770,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 +4028,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 +4197,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 +4379,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,