[cl-pdf-devel] Histogram bug
Björn Lindberg
d95-bli at nada.kth.se
Tue Nov 30 12:29:05 UTC 2004
It seems that it is supposed to be possible to give a format string
for the values on the y axis when creating a histogram instance like
so:
(make-instance 'pdf:histogram ...
:y-axis-options '(:format-string "foo! ~A"))
However, first of all this slot will never be set because there is no
initarg for it in the class value-axis. Secondly, even if it was, it
would be unconditionally clobbered in the compute-scale function.
Below is a patch to chart.lisp with a suggested modification which
remedies both problems.
Björn
--- chart.bak.lisp 2004-11-30 12:36:47.000000000 +0100
+++ chart.lisp 2004-11-30 12:58:30.000000000 +0100
@@ -46,7 +46,7 @@
(axis-min :accessor axis-min)
(axis-max :accessor axis-max)
(nb-subticks :accessor nb-subticks)
- (format-string :accessor format-string)
+ (format-string :accessor format-string :initform nil :initarg :format-string)
))
(defmethod initialize-instance :after ((axis value-axis) &rest init-options &key &allow-other-keys)
@@ -111,10 +111,11 @@
(axis-scale axis) (/ (axis-size axis)(- (axis-max axis) (axis-min axis)))
(ticks-separation axis)(/ (axis-size axis) (1- (nb-ticks axis)))
(format-string axis)
- (if (integer-tick axis)
- "~d"
- (format nil "~~,~df" nfrac))
- (ticks-positions axis)(make-array (nb-ticks axis)))
+ (or (format-string axis)
+ (if (integer-tick axis)
+ "~d"
+ (format nil "~~,~df" nfrac)))
+ (ticks-positions axis) (make-array (nb-ticks axis)))
(loop for tick from 0 below (nb-ticks axis)
for pos from 0 by (ticks-separation axis) do
(setf (aref (ticks-positions axis) tick) pos))))
More information about the cl-pdf-devel
mailing list