summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 50412c1)
raw | patch | inline | side by side (parent: 50412c1)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 11 Apr 2005 23:22:57 +0000 (23:22 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 11 Apr 2005 23:22:57 +0000 (23:22 +0000) |
* re-intruduced --units-length option
* stabilized --units-exponent option by jumping to alt-y-grid mode
once the default autogrid can not cope with the data anymore.
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@397 a5681a0c-68f1-0310-ab6d-d61299d08faa
* stabilized --units-exponent option by jumping to alt-y-grid mode
once the default autogrid can not cope with the data anymore.
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@397 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/doc/rrdgraph.src | patch | blob | history | |
program/src/rrd_graph.c | patch | blob | history | |
program/src/rrd_graph.h | patch | blob | history | |
program/src/rrd_tool.c | patch | blob | history |
index 7f912bed5c5cb7f36eea08aac3cabdbf55fd2837..faee46e21406562bd13d9f12ef511f3160cc1243 100644 (file)
--- a/program/doc/rrdgraph.src
+++ b/program/doc/rrdgraph.src
display the y-axis values in u (Micro, 10e-6, millionths). Use a value
of 0 to prevent any scaling of the y-axis values.
+This option is very effective at confusing the heck out of the default
+rrdtool autoscaler and grid painter. If rrdtool detects that it is not
+successful in labeling the graph under the given circumstances, it will switch
+to the more robust B<--alt-y-grid> mode.
+
+B<[-L|--units-length E<lt>valueE<gt>]>
+
+How many digits should rrdtool assume the y-axis labels to be ? You may have to use this option
+to make enough space once you start fideling with the y-axis labeling.
+
Z<>
=back
index a0748ad800059c892fa133c079991ded45a2f767..0daa551c5707d4401006fa9763585b82dc186d85 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
digits = floor( log( max( fabs(im->minval),fabs(im->maxval)))/log((double)im->base));
}
im->magfact = pow((double)im->base , digits);
-
+
#ifdef DEBUG
printf("digits %6.3f im->magfact %6.3f\n",digits,im->magfact);
#endif
((digits+symbcenter) >= 0) )
im->symbol = symbol[(int)digits+symbcenter];
else
- im->symbol = ' ';
+ im->symbol = '?';
}
/* move min and max values around to become sensible */
-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 */
decimals = 1;
fractionals = floor(log10(range));
- if(fractionals < 0) /* small amplitude. */
- sprintf(im->ygrid_scale.labfmt, "%%%d.%df", decimals - fractionals + 1, -fractionals + 1);
- else
- sprintf(im->ygrid_scale.labfmt, "%%%d.1f", decimals + 1);
+ 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);
if(im->ygrid_scale.gridstep == 0) /* range is one -> 0.1 is reasonable scale */
im->ygrid_scale.gridstep = 0.1;
else {
for(i=0;ylab[i].grid > 0;i++){
pixel = im->ysize / (scaledrange / ylab[i].grid);
- if (gridind == -1 && pixel > 5) {
+ if (pixel > 5) {
gridind = i;
break;
}
}
gfx_new_text ( im->canvas,
- X0-im->text_prop[TEXT_PROP_AXIS].size/1.5, Y0,
+ X0-im->text_prop[TEXT_PROP_AXIS].size, Y0,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
sprintf(graph_label,"%3.0e",value * yloglab[majoridx][i]);
gfx_new_text ( im->canvas,
- X0-im->text_prop[TEXT_PROP_AXIS].size/1.5, Y0,
+ X0-im->text_prop[TEXT_PROP_AXIS].size, Y0,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
# error "your libc has no strftime I guess we'll abort the exercise here."
#endif
gfx_new_text ( im->canvas,
- xtr(im,tilab), Y0+im->text_prop[TEXT_PROP_AXIS].size/1.5,
+ xtr(im,tilab), Y0+im->text_prop[TEXT_PROP_AXIS].size,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
*/
int Xvertical=0, Yvertical=0,
Xtitle =0, Ytitle =0,
- Xylabel =0, Yylabel =0,
+ Xylabel =0,
Xmain =0, Ymain =0,
#ifdef WITH_PIECHART
Xpie =0, Ypie =0,
#endif
- Xxlabel =0, Yxlabel =0,
+ Yxlabel =0,
#if 0
Xlegend =0, Ylegend =0,
#endif
- Xspacing =10, Yspacing =10;
+ Xspacing =15, Yspacing =15;
if (im->extra_flags & ONLY_GRAPH) {
im->xorigin =0;
Xmain=im->xsize;
Ymain=im->ysize;
if (im->draw_x_grid) {
- Xxlabel=Xmain;
Yxlabel=im->text_prop[TEXT_PROP_AXIS].size *2.5;
}
if (im->draw_y_grid) {
- Xylabel=im->text_prop[TEXT_PROP_AXIS].size *6;
- Yylabel=Ymain;
+ Xylabel=gfx_get_text_width(im->canvas, 0,
+ im->text_prop[TEXT_PROP_AXIS].font,
+ im->text_prop[TEXT_PROP_AXIS].size,
+ im->tabwidth,
+ "0", 0) * im->unitslength + im->text_prop[TEXT_PROP_AXIS].size * 2;
}
}
im->minval = DNAN;
im->maxval = DNAN;
im->unitsexponent= 9999;
+ im->unitslength= 5;
im->extra_flags= 0;
im->rigid = 0;
im->gridfit = 1;
{"no-minor", no_argument, 0, 'I'},
{"alt-autoscale", no_argument, 0, 'A'},
{"alt-autoscale-max", no_argument, 0, 'M'},
+ {"no-gridfit", no_argument, 0, 'N'},
{"units-exponent",required_argument, 0, 'X'},
+ {"units-length",required_argument, 0, 'L'},
{"step", required_argument, 0, 'S'},
{"tabwidth", required_argument, 0, 'T'},
- {"no-gridfit", no_argument, 0, 'N'},
{0,0,0,0}};
int option_index = 0;
int opt;
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:S:NT:",
+ "s:e:x:y:v:w:h:iu:l:rb:oc:n:m:t:f:a:I:zgjFYAMX:L:S:T:N",
long_options, &option_index);
if (opt == EOF)
case 'X':
im->unitsexponent = atoi(optarg);
break;
+ case 'L':
+ im->unitslength = atoi(optarg);
+ break;
case 'T':
im->tabwidth = atof(optarg);
break;
case 'S':
im->step = atoi(optarg);
break;
- case 262:
+ case 'N':
im->gridfit = 0;
break;
case 's':
index 1e02c624ad5269788c97c7d9a66a70aac1f7e4a3..cf9964562a4e1c7e4fe7fc437b76efd735278d3f 100644 (file)
--- a/program/src/rrd_graph.h
+++ b/program/src/rrd_graph.h
long base; /* 1000 or 1024 depending on what we graph */
char symbol; /* magnitude symbol for y-axis */
int unitsexponent; /* 10*exponent for units on y-asis */
+ int unitslength; /* width of the yaxis labels */
int extra_flags; /* flags for boolean options */
/* data elements */
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index fb0fafead8c3c1f19f62d6592567df2a00c64be6..784f6dc4a3918ee39f9286044551c6e7244bc057 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
"\t\t[--zoom factor]\n"
"\t\t[--alt-autoscale]\n"
"\t\t[--alt-autoscale-max]\n"
- "\t\t[--units-exponent value]\n"
+ "\t\t[--no-gridfit]\n"
+ "\t\t[--units-exponent value]\n"
+ "\t\t[--units-length value]\n"
"\t\t[--step seconds]\n"
"\t\t[-f|--imginfo printfstr]\n"
"\t\t[-a|--imgformat PNG]\n"