diff --git a/src/rrd_graph.c b/src/rrd_graph.c
index d1f32ddcb650838f6022d6386d79edf81d496a0e..24b58d08bf48b9b8264789aa340aeb382a1c8bc9 100644 (file)
--- a/src/rrd_graph.c
+++ b/src/rrd_graph.c
/****************************************************************************
- * RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.4.2 Copyright by Tobi Oetiker, 1997-2009
****************************************************************************
* rrd__graph.c produce graphs from data in rrdfiles
****************************************************************************/
#include <fcntl.h>
#endif
-#ifdef HAVE_TIME_H
#include <time.h>
-#endif
-#ifdef HAVE_LOCALE_H
#include <locale.h>
-#endif
#include "rrd_graph.h"
#include "rrd_client.h"
} 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)
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 */
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);
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);
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);
{
image_desc_t im;
rrd_info_t *grinfo;
+ char *old_locale;
rrd_graph_init(&im);
/* a dummy surface so that we can measure text sizes for placements */
-
+ old_locale = setlocale(LC_NUMERIC, "C");
rrd_graph_options(argc, argv, &im);
if (rrd_test_error()) {
rrd_info_free(im.grinfo);
}
rrd_graph_script(argc, argv, &im, 1);
+ setlocale(LC_NUMERIC, old_locale); /* reenable locale for rendering the graph */
+
if (rrd_test_error()) {
rrd_info_free(im.grinfo);
im_free(&im);
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;
long long_tmp;
rrd_time_value_t start_tv, end_tv;
long unsigned int color;
- char *old_locale = "";
/* defines for long options without a short equivalent. should be bytes,
and may not collide with (the ASCII value of) short options */
{ "legend-position", required_argument, 0, 1005},
{ "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* */
case LONGOPT_UNITS_SI:
if (im->extra_flags & FORCE_UNITS) {
rrd_set_error("--units can only be used once!");
- setlocale(LC_NUMERIC, old_locale);
return;
}
if (strcmp(optarg, "si") == 0)
im->forceleftspace = 1;
break;
case 'T':
- old_locale = setlocale(LC_NUMERIC, "C");
im->tabwidth = atof(optarg);
- setlocale(LC_NUMERIC, old_locale);
break;
case 'S':
- old_locale = setlocale(LC_NUMERIC, "C");
im->step = atoi(optarg);
- setlocale(LC_NUMERIC, old_locale);
break;
case 'N':
im->gridfit = 0;
im->draw_y_grid = 0;
break;
};
- old_locale = setlocale(LC_NUMERIC, "C");
if (sscanf(optarg, "%lf:%d", &im->ygridstep, &im->ylabfact) == 2) {
- setlocale(LC_NUMERIC, old_locale);
if (im->ygridstep <= 0) {
rrd_set_error("grid step must be > 0");
return;
return;
}
} else {
- setlocale(LC_NUMERIC, old_locale);
rrd_set_error("invalid y-grid format");
return;
}
case 1007:
im->draw_3d_border = atoi(optarg);
break;
+ case 1008: /* grid-dash */
+ if(sscanf(optarg,
+ "%lf:%lf",
+ &im->grid_dash_on,
+ &im->grid_dash_off) != 2) {
+ rrd_set_error("expected grid-dash format float:float");
+ return;
+ }
+ break;
+ case 1009: /* enable dynamic labels */
+ im->dynamic_labels = 1;
+ break;
case 1002: /* right y axis */
if(sscanf(optarg,
im->ylegend[150] = '\0';
break;
case 'u':
- old_locale = setlocale(LC_NUMERIC, "C");
im->maxval = atof(optarg);
- setlocale(LC_NUMERIC, old_locale);
break;
case 'l':
- old_locale = setlocale(LC_NUMERIC, "C");
im->minval = atof(optarg);
- setlocale(LC_NUMERIC, old_locale);
break;
case 'b':
im->base = atol(optarg);
double size = 1;
int end;
- old_locale = setlocale(LC_NUMERIC, "C");
if (sscanf(optarg, "%10[A-Z]:%lf%n", prop, &size, &end) >= 2) {
int sindex, propidx;
- setlocale(LC_NUMERIC, old_locale);
if ((sindex = text_prop_conv(prop)) != -1) {
for (propidx = sindex;
propidx < TEXT_PROP_LAST; propidx++) {
return;
}
} else {
- setlocale(LC_NUMERIC, old_locale);
rrd_set_error("invalid text property format");
return;
}
break;
}
case 'm':
- old_locale = setlocale(LC_NUMERIC, "C");
im->zoom = atof(optarg);
- setlocale(LC_NUMERIC, old_locale);
if (im->zoom <= 0.0) {
rrd_set_error("zoom factor must be > 0");
return;
double param;
char func[30];
int n;
- char *old_locale;
n = 0;
- old_locale = setlocale(LC_NUMERIC, "C");
sscanf(str, "%le,%29[A-Z]%n", ¶m, func, &n);
- setlocale(LC_NUMERIC, old_locale);
if (n == (int) strlen(str)) { /* matched */
;
} else {