----- Original Message ----- From: <hpinson@indepthl.com>
Has anyone gotten the (excellent) ChartDirector charting library to work with zope?
Here's what I have tried:
1. Created an ExternalMethod named barchart.py, in the Extensions folder: #output the chart print "Content-type: image/png\n" binaryPrint(c.makeChart2(PNG))
Where is 'binaryPrint' printing to (a file? stdio?)? I am not familiar with ChartDirector, but with PIL we have to trick it to write to a 'ram file' and then return that, here are the relevant extracts from an external method that uses PIL: <snip> class RamFile: def __init__(self): self.contents = [] def write(self,s): self.contents.append(s) def read(self): return string.join(self.contents,'') </snip> <snip> canvas.drawString("S", 7,263, Font(face="times",size=14,bold=1), color=black, angle=0) canvas.flush() rfile = RamFile() canvas.save(file=rfile,format="jpeg") return rfile.read() </snip> HTH Jonathan