[reportlab-users] Making use of N/A feature in bargraphs

Andy Robinson reportlab-users@reportlab.com
Thu, 14 Nov 2002 01:13:21 -0000

Larry, thanks for the earlier docco patches which I will try to
apply tomorrow.  Going from memory (I'll check for real if
these don't work):
> 1) What data value will trigger the system to regard it as N/A data (zero
> doesn't seem to work)?


> 2) What is proper syntax for setting the label to be printed when N/A data
> is encountered?

Most of our 'format' options accept either a format string
e.g. "%0.2f", or a function (or callable) which takes
strings as arguments.  So you could make a function
like this, which displays 'N/A' for None,
and set it as the value:

   def displayLabel(data):
       if data is None:
           return 'N/A'
           return '%0.2f' % data

Also check out reportlab\lib\formatters which has a configurable
object you can use for money or decimal formats.  It would be
logical to give this an 'N/A' option you could toggle on,
or to inherit from it.