[rrd-developers] placement of y-axis gridlines
Peter Speck
speck at ruc.dk
Thu Apr 11 22:16:45 MEST 2002
Hi everybody,
RRDtool calculates the y-range for the graph without regard to which
height the canvas has (i.e. the number of pixels). This results in
gridlines often falling on non-integer pixel values. Currently this is
handled in the ytr() function (which calculates y-pixel-pos from
y-value) by always returning integer pixel values.
However, this results in uneven vertical spacing of the gridlines, as
can be seen in this screendump (scaled to 200%, 20Kb):
http://www.vitality.dk/rrdtool/yaxis-adjust/uneven-height.png
Look at the spacing between minor gridlines between 4.0 and 6.0: spacing
between minor gridline 1 and 2 is bigger than between 2 and 3.
The round-to-integer functionality in ytr() is too used for hires output
(e.g. eps), which means that the gridlines still have the uneven spacing
even when reproduced on hires printers.
My understanding of the round-to-integer in ytr() is that PNG always
uses integer coordinates to avoid drawing anti-aliased lines caused by
the low resolution. This is not a problem for hires output as a gridline
is several pixels wide.
I can see two different ways of solving the uneven spacing problem:
1) change ytr() so it always return non-truncated coordinates (with all
decimals). Specific imageformat implementations (in rrd_gfx) might
truncate coordinates to integer values or to fixed-decimal (and might
do it only for straight vertical/horizontal lines).
2) change calculation of the y-axis range so that all minor and major
y-gridlines happends to fall on integer y-values.
Solution nr 2 requires that it is allowed to modify the y-axis range
(even if --rigid?). It should however, normally just be a minor
extension of it, so it might/should not be a problem.
For testing this concept, I have implemented both solutions (for
non-logarithmic), as they work together. Solution nr 1 is implemented by
this patch:
http://www.vitality.dk/rrdtool/yaxis-adjust/2002-04-11-yaxishires.diff
note that I have hacked the fileformat specific truncate for PNG into
ytr() for this concept test.
and nr 2 by this:
http://www.vitality.dk/rrdtool/yaxis-adjust/2002-04-11-yaxisadjust.diff
When having this, the screendump for PNG output now looks like this:
http://www.vitality.dk/rrdtool/yaxis-adjust/even-height.png
(even when disabling the PNG truncate!)
Comments, thoughts?
----
- Peter Speck
"The difference between theory and practice
is small in theory and large in practice..."
--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-developers
mailing list