-#define RRD_DEFAULT_FONT "c:/winnt/fonts/COUR.TTF"
-#else
-#define RRD_DEFAULT_FONT "/usr/share/fonts/truetype/openoffice/ariosor.ttf"
+char rrd_win_default_font[80];
+#endif
+
+#ifndef RRD_DEFAULT_FONT
+#ifndef WIN32
+#define RRD_DEFAULT_FONT "VeraMono.ttf"
+/* #define RRD_DEFAULT_FONT "/usr/share/fonts/truetype/openoffice/ariosor.ttf" */
text_prop_t text_prop[] = {
{ 10.0, RRD_DEFAULT_FONT }, /* default */
{ 12.0, RRD_DEFAULT_FONT }, /* title */
text_prop_t text_prop[] = {
{ 10.0, RRD_DEFAULT_FONT }, /* default */
{ 12.0, RRD_DEFAULT_FONT }, /* title */
for(ii=0;ii<im->gdes[i].ds_cnt;ii++){
if(strcmp(im->gdes[i].ds_namv[ii],im->gdes[i].ds_nam) == 0){
im->gdes[i].ds=ii; }
for(ii=0;ii<im->gdes[i].ds_cnt;ii++){
if(strcmp(im->gdes[i].ds_namv[ii],im->gdes[i].ds_nam) == 0){
im->gdes[i].ds=ii; }
if (im->gdes[i].gf == GF_PRINT){
(*prdata)[prlines-2] = malloc((FMT_LEG_LEN+2)*sizeof(char));
sprintf((*prdata)[prlines-2],"%s (%lu)",
if (im->gdes[i].gf == GF_PRINT){
(*prdata)[prlines-2] = malloc((FMT_LEG_LEN+2)*sizeof(char));
sprintf((*prdata)[prlines-2],"%s (%lu)",
(*prdata)[prlines-1] = NULL;
} else {
sprintf(im->gdes[i].legend,"%s (%lu)",
(*prdata)[prlines-1] = NULL;
} else {
sprintf(im->gdes[i].legend,"%s (%lu)",
+
+ /* hid legends for rules which are not displayed */
+
+ if (im->gdes[i].gf == GF_HRULE &&
+ (im->gdes[i].yrule < im->minval || im->gdes[i].yrule > im->maxval))
+ im->gdes[i].legend[0] = '\0';
+
+ if (im->gdes[i].gf == GF_VRULE &&
+ (im->gdes[i].xrule < im->start || im->gdes[i].xrule > im->end))
+ im->gdes[i].legend[0] = '\0';
im->text_prop[TEXT_PROP_LEGEND].font,
im->text_prop[TEXT_PROP_LEGEND].size,
im->tabwidth,
im->text_prop[TEXT_PROP_LEGEND].font,
im->text_prop[TEXT_PROP_LEGEND].size,
im->tabwidth,
im->text_prop[TEXT_PROP_LEGEND].font,
im->text_prop[TEXT_PROP_LEGEND].size,
im->tabwidth,
im->text_prop[TEXT_PROP_LEGEND].font,
im->text_prop[TEXT_PROP_LEGEND].size,
im->tabwidth,
- strftime(graph_label,99,im->xlab_user.stst,localtime(&tilab));
+ localtime_r(&tilab, &tm);
+ strftime(graph_label,99,im->xlab_user.stst, &tm);
gfx_new_text( im->canvas,
7, (im->yorigin - im->ysize/2),
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
gfx_new_text( im->canvas,
7, (im->yorigin - im->ysize/2),
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
- im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0,
- GFX_H_CENTER, GFX_V_CENTER,
+ im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth,
+ RRDGRAPH_YLEGEND_ANGLE,
+ GFX_H_LEFT, GFX_V_CENTER,
- gfx_new_text(im->canvas,7,im->text_prop[TEXT_PROP_AXIS].size*(l-n),
+ gfx_new_text(im->canvas,7,im->text_prop[TEXT_PROP_AXIS].size*(n+1),
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0,
boxH = gfx_get_text_width(im->canvas, 0,
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
boxH = gfx_get_text_width(im->canvas, 0,
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
- if (im->ylegend[0] != '\0') {
- Xvertical = im->text_prop[TEXT_PROP_LEGEND].size *2;
- Yvertical = im->text_prop[TEXT_PROP_LEGEND].size * (strlen(im->ylegend)+1);
+ if (im->extra_flags & ONLY_GRAPH) {
+ if ( im->ysize > 32 ) {
+ rrd_set_error("height > 32 is not possible with --only-graph option");
+ return -1;
+ }
+ Xspacing =0;
+ Yspacing =0;
+ } else {
+ if (im->ylegend[0] != '\0') {
+ Xvertical = im->text_prop[TEXT_PROP_LEGEND].size *2;
+ Yvertical = im->text_prop[TEXT_PROP_LEGEND].size * (strlen(im->ylegend)+1);
+ }
im->text_prop[TEXT_PROP_TITLE].font,
im->text_prop[TEXT_PROP_TITLE].size,
im->tabwidth,
im->text_prop[TEXT_PROP_TITLE].font,
im->text_prop[TEXT_PROP_TITLE].size,
im->tabwidth,
/**************************************************************
*** Calculating sizes and locations became a bit confusing ***
*** so I moved this into a separate function. ***
/**************************************************************
*** Calculating sizes and locations became a bit confusing ***
*** so I moved this into a separate function. ***
/* make sure we do not run into trouble when stacking on NaN */
for(ii=0;ii<im->xsize;ii++){
if (isnan(im->gdes[i].p_data[ii])) {
/* make sure we do not run into trouble when stacking on NaN */
for(ii=0;ii<im->xsize;ii++){
if (isnan(im->gdes[i].p_data[ii])) {
- double ybase = 0.0;
- if (lastgdes) {
- ybase = ytr(im,lastgdes->p_data[ii-1]);
- };
- if (isnan(ybase) || !lastgdes ){
- ybase = ytr(im,areazero);
+ if (lastgdes && (im->gdes[i].gf == GF_STACK)) {
+ im->gdes[i].p_data[ii] = lastgdes->p_data[ii];
+ } else {
+ im->gdes[i].p_data[ii] = ytr(im,areazero);
} else {
if ((fo = fopen(im->graphfile,"wb")) == NULL) {
rrd_set_error("Opening '%s' for write: %s",im->graphfile,
} else {
if ((fo = fopen(im->graphfile,"wb")) == NULL) {
rrd_set_error("Opening '%s' for write: %s",im->graphfile,
-rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize)
+rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize, FILE *stream)
+#ifdef WIN32
+ {
+ char *windir;
+ windir = getenv("windir");
+ /* %windir% is something like D:\windows or C:\winnt */
+ if (windir != NULL) {
+ strcpy(rrd_win_default_font,windir);
+ strcat(rrd_win_default_font,"\\fonts\\cour.ttf");
+ for(i=0;i<DIM(text_prop);i++)
+ text_prop[i].font = rrd_win_default_font;
+ }
+ }
+#endif
for(i=0;i<DIM(text_prop);i++){
im->text_prop[i].size = text_prop[i].size;
im->text_prop[i].font = text_prop[i].font;
for(i=0;i<DIM(text_prop);i++){
im->text_prop[i].size = text_prop[i].size;
im->text_prop[i].font = text_prop[i].font;
char scan_gtm[12],scan_mtm[12],scan_ltm[12],col_nam[12];
time_t start_tmp=0,end_tmp=0;
long long_tmp;
char scan_gtm[12],scan_mtm[12],scan_ltm[12],col_nam[12];
time_t start_tmp=0,end_tmp=0;
long long_tmp;
{"lazy", no_argument, 0, 'z'},
{"zoom", required_argument, 0, 'm'},
{"no-legend", no_argument, 0, 'g'},
{"lazy", no_argument, 0, 'z'},
{"zoom", required_argument, 0, 'm'},
{"no-legend", no_argument, 0, 'g'},
{"alt-y-grid", no_argument, 0, 'Y'},
{"no-minor", no_argument, 0, 'I'},
{"alt-autoscale", no_argument, 0, 'A'},
{"alt-y-grid", no_argument, 0, 'Y'},
{"no-minor", no_argument, 0, 'I'},
{"alt-autoscale", no_argument, 0, 'A'},