/****************************************************************************
- * RRDtool 1.2.1 Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.6 Copyright by Tobi Oetiker, 1997-2005
****************************************************************************
* rrd__graph.c produce graphs from data in rrdfiles
****************************************************************************/
if (! im->rigid) {
/* keep yval as-is */
} else if (yval > im->yorigin) {
- yval = im->yorigin+2;
+ yval = im->yorigin;
} else if (yval < im->yorigin - im->ysize){
- yval = im->yorigin - im->ysize - 2;
+ yval = im->yorigin - im->ysize;
}
return yval;
}
* and the resulting number is the step size for the
* resulting data source.
*/
- for(rpi=0;im->gdes[gdi].rpnp[rpi].op != OP_END;rpi++){
- if(im->gdes[gdi].rpnp[rpi].op == OP_VARIABLE ||
- im->gdes[gdi].rpnp[rpi].op == OP_PREV_OTHER){
- long ptr = im->gdes[gdi].rpnp[rpi].ptr;
- if (im->gdes[ptr].ds_cnt == 0) {
+ for(rpi=0;im->gdes[gdi].rpnp[rpi].op != OP_END;rpi++){
+ if(im->gdes[gdi].rpnp[rpi].op == OP_VARIABLE ||
+ im->gdes[gdi].rpnp[rpi].op == OP_PREV_OTHER){
+ long ptr = im->gdes[gdi].rpnp[rpi].ptr;
+ if (im->gdes[ptr].ds_cnt == 0) { /* this is a VDEF data source */
#if 0
- printf("DEBUG: inside CDEF '%s' processing VDEF '%s'\n",
- im->gdes[gdi].vname,
- im->gdes[ptr].vname);
- printf("DEBUG: value from vdef is %f\n",im->gdes[ptr].vf.val);
+ printf("DEBUG: inside CDEF '%s' processing VDEF '%s'\n",
+ im->gdes[gdi].vname,
+ im->gdes[ptr].vname);
+ printf("DEBUG: value from vdef is %f\n",im->gdes[ptr].vf.val);
#endif
im->gdes[gdi].rpnp[rpi].val = im->gdes[ptr].vf.val;
im->gdes[gdi].rpnp[rpi].op = OP_NUMBER;
- } else {
- if ((steparray =
+ } else { /* normal variables and PREF(variables) */
+
+ /* add one entry to the array that keeps track of the step sizes of the
+ * data sources going into the CDEF. */
+ if ((steparray =
rrd_realloc(steparray,
(++stepcnt+1)*sizeof(*steparray)))==NULL){
- rrd_set_error("realloc steparray");
- rpnstack_free(&rpnstack);
- return -1;
+ rrd_set_error("realloc steparray");
+ rpnstack_free(&rpnstack);
+ return -1;
};
steparray[stepcnt-1] = im->gdes[ptr].step;
* to the earliest endpoint of any of the
* rras involved (ptr)
*/
+
if(im->gdes[gdi].start < im->gdes[ptr].start)
im->gdes[gdi].start = im->gdes[ptr].start;
* further save step size and data source
* count of this rra
*/
- im->gdes[gdi].rpnp[rpi].data = im->gdes[ptr].data + im->gdes[ptr].ds;
- im->gdes[gdi].rpnp[rpi].step = im->gdes[ptr].step;
+ im->gdes[gdi].rpnp[rpi].data = im->gdes[ptr].data + im->gdes[ptr].ds;
+ im->gdes[gdi].rpnp[rpi].step = im->gdes[ptr].step;
im->gdes[gdi].rpnp[rpi].ds_cnt = im->gdes[ptr].ds_cnt;
/* backoff the *.data ptr; this is done so
/* move the data pointers to the correct period */
for(rpi=0;im->gdes[gdi].rpnp[rpi].op != OP_END;rpi++){
- if(im->gdes[gdi].rpnp[rpi].op == OP_VARIABLE ||
- im->gdes[gdi].rpnp[rpi].op == OP_PREV_OTHER){
- long ptr = im->gdes[gdi].rpnp[rpi].ptr;
+ if(im->gdes[gdi].rpnp[rpi].op == OP_VARIABLE ||
+ im->gdes[gdi].rpnp[rpi].op == OP_PREV_OTHER){
+ long ptr = im->gdes[gdi].rpnp[rpi].ptr;
long diff = im->gdes[gdi].start - im->gdes[ptr].start;
if(diff > 0)
else {
for(i=0;ylab[i].grid > 0;i++){
pixel = im->ysize / (scaledrange / ylab[i].grid);
- if (pixel > 5) {
+ if (pixel > 7) {
gridind = i;
break;
}
}
for(i=0; i<4;i++) {
- if (pixel * ylab[gridind].lfac[i] >= 2 * im->text_prop[TEXT_PROP_AXIS].size) {
+ if (pixel * ylab[gridind].lfac[i] >= 2.5 * im->text_prop[TEXT_PROP_AXIS].size) {
im->ygrid_scale.labfact = ylab[gridind].lfac[i];
break;
}
int sgrid = (int)( im->minval / im->ygrid_scale.gridstep - 1);
int egrid = (int)( im->maxval / im->ygrid_scale.gridstep + 1);
+ double MaxY;
scaledstep = im->ygrid_scale.gridstep/im->magfact;
+ MaxY = scaledstep*(double)im->viewfactor*(double)egrid;
for (i = sgrid; i <= egrid; i++){
double Y0=ytr(im,im->ygrid_scale.gridstep*i);
if ( Y0 >= im->yorigin-im->ysize
&& Y0 <= im->yorigin){
if(i % im->ygrid_scale.labfact == 0){
if (i==0 || im->symbol == ' ') {
- if(scaledstep < 1){
+ if(MaxY < 10) {
if(im->extra_flags & ALTYGRID) {
sprintf(graph_label,im->ygrid_scale.labfmt,scaledstep*im->viewfactor*i);
}
sprintf(graph_label,"%4.0f",scaledstep*im->viewfactor*i);
}
}else {
- if(scaledstep < 1){
+ if(MaxY < 10){
sprintf(graph_label,"%4.1f %c",scaledstep*im->viewfactor*i, im->symbol);
} else {
sprintf(graph_label,"%4.0f %c",scaledstep*im->viewfactor*i, im->symbol);
} else {
res = draw_horizontal_grid(im);
}
-
+
/* dont draw horizontal grid if there is no min and max val */
if (! res ) {
char *nodata = "No Data found";
/* yaxis unit description */
gfx_new_text( im->canvas,
- 12, (im->yorigin - im->ysize/2),
+ 10, (im->yorigin - im->ysize/2),
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_UNIT].font,
im->text_prop[TEXT_PROP_UNIT].size, im->tabwidth,
im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, 0.0,
GFX_H_CENTER, GFX_V_CENTER,
im->title);
+ /* rrdtool 'logo' */
+ gfx_new_text( im->canvas,
+ im->ximg-7, 7,
+ ( im->graph_col[GRC_FONT] & 0xffffff00 ) | 0x00000044,
+ im->text_prop[TEXT_PROP_AXIS].font,
+ 5.5, im->tabwidth, 270,
+ GFX_H_RIGHT, GFX_V_TOP,
+ "RRDTOOL / TOBI OETIKER");
/* graph labels */
if( !(im->extra_flags & NOLEGEND) & !(im->extra_flags & ONLY_GRAPH) ) {
if ( im->gdes[i].gf != GF_PRINT &&
im->gdes[i].gf != GF_GPRINT &&
im->gdes[i].gf != GF_COMMENT) {
- int boxH, boxV;
+ int boxL, boxH, boxV;
- boxH = gfx_get_text_width(im->canvas, 0,
+ boxL = gfx_get_text_width(im->canvas, 0,
im->text_prop[TEXT_PROP_LEGEND].font,
im->text_prop[TEXT_PROP_LEGEND].size,
- im->tabwidth,"M", 0)*1.2;
- boxV = boxH;
+ im->tabwidth,"oo", 0);
+ boxH = boxL / 1.9;
+ boxV = boxH+1;
/* make sure transparent colors show up all the same */
+ node = gfx_new_area(im->canvas,
+ X0-1,Y0-boxV,
+ X0-1,Y0+1,
+ X0+boxL+0.5,Y0+1,
+ im->graph_col[GRC_BACK]);
+ gfx_add_point ( node, X0+boxL+0.5, Y0-boxV );
node = gfx_new_area(im->canvas,
- X0,Y0-boxV,
- X0,Y0,
+ X0-1,Y0-boxV,
+ X0-1,Y0,
X0+boxH,Y0,
im->graph_col[GRC_CANVAS]);
gfx_add_point ( node, X0+boxH, Y0-boxV );
node = gfx_new_area(im->canvas,
- X0,Y0-boxV,
- X0,Y0,
+ X0-1,Y0-boxV,
+ X0-1,Y0,
X0+boxH,Y0,
im->gdes[i].col);
gfx_add_point ( node, X0+boxH, Y0-boxV );
node = gfx_new_line(im->canvas,
- X0,Y0-boxV, X0,Y0,
+ X0-1,Y0-boxV,
+ X0-1,Y0,
1,im->graph_col[GRC_FONT]);
gfx_add_point(node,X0+boxH,Y0);
gfx_add_point(node,X0+boxH,Y0-boxV);
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
im->tabwidth,
- "0", 0) * im->unitslength + Xspacing;
+ "0", 0) * im->unitslength;
}
}
} /* for */
/* *******************************************************
- ___
- | | ___
+ a ___. (a,t)
+ | | ___
____| | | |
| |___|
- -------|---------------------------------------
+ -------|--t-1--t--------------------------------
- if we know the value of y at time t was a then
+ if we know the value at time t was a then
we draw a square from t-1 to t with the value a.
********************************************************* */
/* GF_LINE and friend */
if(stack_gf == GF_LINE ){
node = NULL;
- for(ii=1;ii<im->xsize;ii++){
- if (isnan(im->gdes[i].p_data[ii])){
+ for(ii=1;ii<im->xsize;ii++){
+ if (isnan(im->gdes[i].p_data[ii]) || (im->slopemode==1 && isnan(im->gdes[i].p_data[ii-1]))){
node = NULL;
continue;
}
if ( node == NULL ) {
- node = gfx_new_line(im->canvas,
+ if ( im->slopemode == 0 ){
+ node = gfx_new_line(im->canvas,
ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii]),
ii+im->xorigin,ytr(im,im->gdes[i].p_data[ii]),
im->gdes[i].linewidth,
im->gdes[i].col);
+ } else {
+ node = gfx_new_line(im->canvas,
+ ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii-1]),
+ ii+im->xorigin,ytr(im,im->gdes[i].p_data[ii]),
+ im->gdes[i].linewidth,
+ im->gdes[i].col);
+ }
} else {
- gfx_add_point(node,ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii]));
+ if ( im->slopemode==0 ){
+ gfx_add_point(node,ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii]));
+ };
gfx_add_point(node,ii+im->xorigin,ytr(im,im->gdes[i].p_data[ii]));
};
}
} else {
- for(ii=1;ii<im->xsize;ii++){
+ float ybase0 = DNAN,ytop0=DNAN;
+ for(ii=0;ii<im->xsize;ii++){
/* keep things simple for now, just draw these bars
do not try to build a big and complex area */
float ybase,ytop;
+ if ( im->slopemode == 0 && ii==0){
+ continue;
+ }
if ( isnan(im->gdes[i].p_data[ii]) ) {
+ ybase0 = DNAN;
continue;
}
ytop = ytr(im,im->gdes[i].p_data[ii]);
- if ( im->gdes[i].stack ) {
+ if ( lastgdes && im->gdes[i].stack ) {
ybase = ytr(im,lastgdes->p_data[ii]);
} else {
ybase = ytr(im,areazero);
}
if ( ybase == ytop ){
- continue;
+ ybase0 = DNAN;
+ continue;
+ }
+ /* every area has to be wound clock-wise,
+ so we have to make sur base remains base */
+ if (ybase > ytop){
+ float extra = ytop;
+ ytop = ybase;
+ ybase = extra;
}
- node = gfx_new_area(im->canvas,
- ii-1+im->xorigin,ybase,
- ii-1+im->xorigin,ytop,
+ if ( im->slopemode == 0){
+ ybase0 = ybase;
+ ytop0 = ytop;
+ }
+ if ( !isnan(ybase0) ){
+ node = gfx_new_area(im->canvas,
+ ii-1+im->xorigin,ybase0,
+ ii-1+im->xorigin,ytop0,
ii+im->xorigin,ytop,
im->gdes[i].col
);
- gfx_add_point(node,ii+im->xorigin,ybase);
+ gfx_add_point(node,
+ ii+im->xorigin,ybase
+ );
+ }
+ ybase0=ybase;
+ ytop0=ytop;
}
} /* else GF_LINE */
} /* if color != 0x0 */
im->gridfit = 1;
im->imginfo = NULL;
im->lazy = 0;
+ im->slopemode = 0;
im->logarithmic = 0;
im->ygridstep = DNAN;
im->draw_x_grid = 1;
{"only-graph", no_argument, 0, 'j'},
{"alt-y-grid", no_argument, 0, 'Y'},
{"no-minor", no_argument, 0, 'I'},
+ {"slope-mode", no_argument, 0, 'E'},
{"alt-autoscale", no_argument, 0, 'A'},
{"alt-autoscale-max", no_argument, 0, 'M'},
{"no-gridfit", no_argument, 0, 'N'},
int col_start,col_end;
opt = getopt_long(argc, argv,
- "s:e:x:y:v:w:h:iu:l:rb:oc:n:m:t:f:a:I:zgjFYAMX:L:S:T:NR:B:",
+ "s:e:x:y:v:w:h:iu:l:rb:oc:n:m:t:f:a:I:zgjFYAMEX:L:S:T:NR:B:",
long_options, &option_index);
if (opt == EOF)
case 'z':
im->lazy = 1;
break;
+ case 'E':
+ im->slopemode = 1;
+ break;
+
case 'o':
im->logarithmic = 1;
if (isnan(im->minval))