[reportlab-users] Problem creating Flowable SpiderChart

Max M maxm at mxm.dk
Thu Jun 2 09:40:10 EDT 2005


I am trying to create a new flowable that renders a spider chart, but 
when I open the pdf document I cannot see the graph.

I have used tables, paragraphs etc. with no problem, so the code is sound.

Can anybody see what I am doing wrong?


from reportlab.graphics.charts.spider import SpiderChart

class mxmGraph(Flowable):

    """Spider flowable"""

    def __init__(self):
        Flowable.__init__(self)
        self.width = 300
        self.height = 300
        self.hAlign = 'CENTRE'

    def __repr__(self):
        return "mxmGraph(title=%s)" % (self.text,)

    def draw(self):
        pc = SpiderChart()
        pc.x = 50
        pc.y = 50
        pc.width = 300
        pc.height = 300
        pc.data = [[10,12,14,16,14,12], [6,8,10,12,9,15],[7,8,17,4,12,8,3]]
        pc.labels = ['U','V','W','X','Y','Z']
        pc.strands.strokeWidth = 2
        pc.strands[0].fillColor = None
        pc.strands[1].fillColor = None
        pc.strands[2].fillColor = None
        pc.strands[0].strokeColor = colors.red
        pc.strands[1].strokeColor = colors.blue
        pc.strands[2].strokeColor = colors.green
        pc.strands.markers = 1
        pc.strands.markerType = "FilledDiamond"
        pc.strands.markerSize = 6
        pc.draw()
        self.canv = pc



if __name__ == '__main__':

   
    f = StringIO()
    doc = SimpleDocTemplate(f)
    doc.build([mxmGraph()], onFirstPage=laterPages, onLaterPages=laterPages)
    pdf_data = f.getvalue()
   
    # save to file
    out = open('mxmGraph.pdf', 'wb')
    out.write(pdf_data)
    out.close()


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science



More information about the reportlab-users mailing list