'Output the chart as a PNG embedded in an IMG tag
- used by the Delphi module'

def draw(self, output='xml'):

    fig = self.fig
    if (not fig):
        return 'Matplotlib    not    installed'
    chart = Storage()
    chart.body = StringIO()
    chart.headers = Storage()
    chart.headers['Content-Type'] = 'image/png'
    canvas = self.FigureCanvas(fig)
    canvas.print_figure(chart.body)
    image = chart.body.getvalue()
    cachePath = self.storeCachedFile(self.filename, image)
    if (output == 'xml'):
        if (cachePath != None):
            image = IMG(_src=cachePath)
        else:
            import base64
            base64Img = base64.b64encode(image)
            image = IMG(_src=('data:image/png;base64,%s' % base64Img))
    else:
        current.response.headers['Content-Type'] = 'image/png'
    return image
