* rrd__graph.c make creates ne rrds
****************************************************************************/
-#if 0
-#include "rrd_tool.h"
-#endif
#include <sys/stat.h>
+
+#include "rrd_tool.h"
+
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
#endif
+
#ifdef HAVE_TIME_H
#include <time.h>
#endif
+
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
conv_if(CDEF,GF_CDEF)
conv_if(VDEF,GF_VDEF)
conv_if(PART,GF_PART)
+ conv_if(XPORT,GF_XPORT)
return (-1);
}
conv_if(PNG,IF_PNG)
conv_if(SVG,IF_SVG)
conv_if(EPS,IF_EPS)
+ conv_if(PDF,IF_PDF)
return (-1);
}
* so CDEFs can use VDEFs and vice versa
*/
switch (im->gdes[gdi].gf) {
+ case GF_XPORT:
+ break;
case GF_VDEF:
/* A VDEF has no DS. This also signals other parts
* of rrdtool that this is a VDEF value, not a CDEF.
case GF_CDEF:
case GF_VDEF:
case GF_PART:
+ case GF_XPORT:
break;
}
}
case GF_CDEF:
case GF_VDEF:
case GF_PART:
+ case GF_XPORT:
break;
}
}
im->text_prop[TEXT_PROP_AXIS].size,
im->tabwidth, 0.0, GFX_H_RIGHT, GFX_V_CENTER,
graph_label );
- gfx_new_line ( im->canvas,
+ gfx_new_dashed_line ( im->canvas,
X0-2,Y0,
X1+2,Y0,
- MGRIDWIDTH, im->graph_col[GRC_MGRID] );
+ MGRIDWIDTH, im->graph_col[GRC_MGRID],
+ im->grid_dash_on, im->grid_dash_off);
} else {
- gfx_new_line ( im->canvas,
+ gfx_new_dashed_line ( im->canvas,
X0-1,Y0,
X1+1,Y0,
- GRIDWIDTH, im->graph_col[GRC_GRID] );
+ GRIDWIDTH, im->graph_col[GRC_GRID],
+ im->grid_dash_on, im->grid_dash_off);
}
}
while(yloglab[minoridx][++i] > 0){
Y0 = ytr(im,value * yloglab[minoridx][i]);
if (Y0 <= im->yorigin - im->ysize) break;
- gfx_new_line ( im->canvas,
+ gfx_new_dashed_line ( im->canvas,
X0-1,Y0,
X1+1,Y0,
- GRIDWIDTH, im->graph_col[GRC_GRID] );
+ GRIDWIDTH, im->graph_col[GRC_GRID],
+ im->grid_dash_on, im->grid_dash_off);
}
}
while(yloglab[majoridx][++i] > 0){
Y0 = ytr(im,value * yloglab[majoridx][i]);
if (Y0 <= im->yorigin - im->ysize) break;
- gfx_new_line ( im->canvas,
+ gfx_new_dashed_line ( im->canvas,
X0-2,Y0,
X1+2,Y0,
- MGRIDWIDTH, im->graph_col[GRC_MGRID] );
+ MGRIDWIDTH, im->graph_col[GRC_MGRID],
+ im->grid_dash_on, im->grid_dash_off);
sprintf(graph_label,"%3.0e",value * yloglab[majoridx][i]);
gfx_new_text ( im->canvas,
image_desc_t *im )
{
int xlab_sel; /* which sort of label and grid ? */
- time_t ti, tilab;
+ time_t ti, tilab, timajor;
long factor;
char graph_label[100];
double X0,Y0,Y1; /* points for filled graph and more*/
/* paint the minor grid */
for(ti = find_first_time(im->start,
im->xlab_user.gridtm,
- im->xlab_user.gridst);
+ im->xlab_user.gridst),
+ timajor = find_first_time(im->start,
+ im->xlab_user.mgridtm,
+ im->xlab_user.mgridst);
ti < im->end;
ti = find_next_time(ti,im->xlab_user.gridtm,im->xlab_user.gridst)
){
/* are we inside the graph ? */
if (ti < im->start || ti > im->end) continue;
+ while (timajor < ti) {
+ timajor = find_next_time(timajor,
+ im->xlab_user.mgridtm, im->xlab_user.mgridst);
+ }
+ if (ti == timajor) continue; /* skip as falls on major grid line */
X0 = xtr(im,ti);
- gfx_new_line(im->canvas,X0,Y0+1, X0,Y1-1,GRIDWIDTH, im->graph_col[GRC_GRID]);
+ gfx_new_dashed_line(im->canvas,X0,Y0+1, X0,Y1-1,GRIDWIDTH,
+ im->graph_col[GRC_GRID],
+ im->grid_dash_on, im->grid_dash_off);
}
/* are we inside the graph ? */
if (ti < im->start || ti > im->end) continue;
X0 = xtr(im,ti);
- gfx_new_line(im->canvas,X0,Y0+2, X0,Y1-2,MGRIDWIDTH, im->graph_col[GRC_MGRID]);
+ gfx_new_dashed_line(im->canvas,X0,Y0+3, X0,Y1-2,MGRIDWIDTH,
+ im->graph_col[GRC_MGRID],
+ im->grid_dash_on, im->grid_dash_off);
}
/* paint the labels below the graph */
case GF_COMMENT:
case GF_HRULE:
case GF_VRULE:
+ case GF_XPORT:
break;
case GF_TICK:
for (ii = 0; ii < im->xsize; ii++)
tzset();
#endif
#ifdef HAVE_SETLOCALE
- setlocale(LC_ALL,"");
+ setlocale(LC_TIME,"");
#endif
im->gdes_c = 0;
im->gdes = NULL;
im->canvas = gfx_new_canvas();
+ im->grid_dash_on = 1;
+ im->grid_dash_off = 1;
for(i=0;i<DIM(graph_col);i++)
im->graph_col[i]=graph_col[i];
/* If the error string is set, we exit at the end of the switch */
switch (gdp->gf) {
+ case GF_XPORT:
+ break;
case GF_COMMENT:
if (rrd_graph_legend(gdp,&line[argstart])==0)
rrd_set_error("Cannot parse comment in line: %s",line);
int bad_format(char *fmt) {
- char *ptr;
- int n=0;
-
- ptr = fmt;
- while (*ptr != '\0') {
- if (*ptr == '%') {ptr++;
- if (*ptr == '\0') return 1;
- while ((*ptr >= '0' && *ptr <= '9') || *ptr == '.') {
- ptr++;
- }
- if (*ptr == '\0') return 1;
- if (*ptr == 'l') {
- ptr++;
- n++;
- if (*ptr == '\0') return 1;
- if (*ptr == 'e' || *ptr == 'f') {
- ptr++;
- } else { return 1; }
- }
- else if (*ptr == 's' || *ptr == 'S' || *ptr == '%') { ++ptr; }
- else { return 1; }
- } else {
- ++ptr;
- }
- }
- return (n!=1);
+ char *ptr;
+ int n=0;
+ ptr = fmt;
+ while (*ptr != '\0')
+ if (*ptr++ == '%') {
+
+ /* line cannot end with percent char */
+ if (*ptr == '\0') return 1;
+
+ /* '%s', '%S' and '%%' are allowed */
+ if (*ptr == 's' || *ptr == 'S' || *ptr == '%') ptr++;
+
+ /* or else '% 6.2lf' and such are allowed */
+ else {
+
+ /* optional padding character */
+ if (*ptr == ' ' || *ptr == '+' || *ptr == '-') ptr++;
+
+ /* This should take care of 'm.n' with all three optional */
+ while (*ptr >= '0' && *ptr <= '9') ptr++;
+ if (*ptr == '.') ptr++;
+ while (*ptr >= '0' && *ptr <= '9') ptr++;
+
+ /* Either 'le' or 'lf' must follow here */
+ if (*ptr++ != 'l') return 1;
+ if (*ptr == 'e' || *ptr == 'f') ptr++;
+ else return 1;
+ n++;
+ }
+ }
+
+ return (n!=1);
}
+
+
int
vdef_parse(gdes,str)
struct graph_desc_t *gdes;
};
return 0;
}
+
+
int
vdef_calc(im,gdi)
image_desc_t *im;