summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a4a4e6e)
raw | patch | inline | side by side (parent: a4a4e6e)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 12 Jun 2005 20:00:07 +0000 (20:00 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 12 Jun 2005 20:00:07 +0000 (20:00 +0000) |
program/src/rrd_graph.c | patch | blob | history |
index ebd91fb0c07d3aa2981db2f83e983c6d63aa8263..7259eef6c7e4155fe474e518d75e90e770f92137 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
delt = im->maxval - im->minval;
adj = delt * 0.1;
fact = 2.0 * pow(10.0,
- floor(log10(max(fabs(im->minval), fabs(im->maxval)))) - 2);
+ floor(log10(max(fabs(im->minval), fabs(im->maxval))/im->magfact)) - 2);
if (delt < fact) {
adj = (fact - delt) * 0.55;
#ifdef DEBUG
-sensiblevalues[i] >=scaled_max)
im->maxval = -sensiblevalues[i]*(im->magfact);
}
- /* no sensiblevalues found. we switch to ALTYGRID mode */
- if (sensiblevalues[i] == 0){
- im->extra_flags |= ALTYGRID;
- }
}
} else {
/* adjust min and max to the grid definition if there is one */
if(isnan(im->ygridstep)){
if(im->extra_flags & ALTYGRID) {
/* find the value with max number of digits. Get number of digits */
- decimals = ceil(log10(max(fabs(im->maxval), fabs(im->minval))));
+ decimals = ceil(log10(max(fabs(im->maxval), fabs(im->minval))*im->viewfactor/im->magfact));
if(decimals <= 0) /* everything is small. make place for zero */
decimals = 1;
- fractionals = floor(log10(range));
- if(fractionals < 0) { /* small amplitude. */
- int len = decimals - fractionals + 1;
- if (im->unitslength < len) im->unitslength = len;
- sprintf(im->ygrid_scale.labfmt, "%%%d.%df", len, -fractionals + 1);
- } else {
- int len = decimals + 1;
- if (im->unitslength < len) im->unitslength = len;
- sprintf(im->ygrid_scale.labfmt, "%%%d.1f", len);
- }
- im->ygrid_scale.gridstep = pow((double)10, (double)fractionals);
+ im->ygrid_scale.gridstep = pow((double)10, floor(log10(range)));
+
if(im->ygrid_scale.gridstep == 0) /* range is one -> 0.1 is reasonable scale */
im->ygrid_scale.gridstep = 0.1;
/* should have at least 5 lines but no more then 15 */
im->ygrid_scale.gridstep /= 5;
im->ygrid_scale.labfact = 5;
}
+ fractionals = floor(log10(im->ygrid_scale.gridstep*(double)im->ygrid_scale.labfact*im->viewfactor/im->magfact));
+ if(fractionals < 0) { /* small amplitude. */
+ int len = decimals - fractionals + 1;
+ if (im->unitslength < len+2) im->unitslength = len+2;
+ sprintf(im->ygrid_scale.labfmt, "%%%d.%df%s", len, -fractionals,(im->symbol != ' ' ? " %c" : ""));
+ } else {
+ int len = decimals + 1;
+ if (im->unitslength < len+2) im->unitslength = len+2;
+ sprintf(im->ygrid_scale.labfmt, "%%%d.1f%s", len, ( im->symbol != ' ' ? " %c" : "" ));
+ }
}
else {
for(i=0;ylab[i].grid > 0;i++){
if ( Y0 >= im->yorigin-im->ysize
&& Y0 <= im->yorigin){
if(i % im->ygrid_scale.labfact == 0){
- if (i==0 || im->symbol == ' ') {
- if(MaxY < 10) {
- if(im->extra_flags & ALTYGRID) {
- sprintf(graph_label,im->ygrid_scale.labfmt,scaledstep*im->viewfactor*i);
- }
- else {
- sprintf(graph_label,"%4.1f",scaledstep*im->viewfactor*i);
- }
- } else {
- sprintf(graph_label,"%4.0f",scaledstep*im->viewfactor*i);
- }
+ if (im->symbol == ' ') {
+ if(im->extra_flags & ALTYGRID) {
+ sprintf(graph_label,im->ygrid_scale.labfmt,scaledstep*im->viewfactor*i);
+ } else {
+ if(MaxY < 10) {
+ sprintf(graph_label,"%4.1f",scaledstep*im->viewfactor*i);
+ } else {
+ sprintf(graph_label,"%4.0f",scaledstep*im->viewfactor*i);
+ }
+ }
}else {
- 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);
- }
+ char sisym = ( i == 0 ? ' ' : im->symbol);
+ if(im->extra_flags & ALTYGRID) {
+ sprintf(graph_label,im->ygrid_scale.labfmt,scaledstep*im->viewfactor*i,sisym);
+ } else {
+ if(MaxY < 10){
+ sprintf(graph_label,"%4.1f %c",scaledstep*im->viewfactor*i, sisym);
+ } else {
+ sprintf(graph_label,"%4.0f %c",scaledstep*im->viewfactor*i, sisym);
+ }
+ }
}
gfx_new_text ( im->canvas,