I'm having difficulty with this.  Here is my code:

def barPlot(data):
    from matplotlib.backends.backend_agg import FigureCanvasAgg as 
FigureCanvas
    from matplotlib.figure import Figure
    import cStringIO
    
    stream = cStringIO.StringIO()
    
    cx = data.keys()
    cy = data.values()

    print cy
    
    fig = Figure()
    canvas = FigureCanvas(fig)
    
    ax = fig.add_subplot(1,1,1)

    ax.plot(cx, cy)
    ax.set_title('hi mom')
    ax.grid(True)
    ax.set_xlabel('time')
    ax.set_ylabel('volts')
    
    canvas.print_png(stream)
    
    return stream.getvalue()


cx is a list of dates, cy is a list of numbers

the function is being called using:

barChart = barPlot(barData)
        
    return dict(fr=fullrange, bc=IMG(_src=URL('barChart'+'.png')))

and my view page code is as follows:


{{extend 'layout.html'}}
<!-- {{=BEAUTIFY(response._vars)}} -->

{{=bc}}


I'm constantly winding up with no image, but it's pointing to barchart.png, 
which does not seem to exist.

On Monday, January 16, 2012 2:33:19 PM UTC-5, Massimo Di Pierro wrote:

def image(): 
>     return myimage() 
>
> myimage returns the binary data of the image. so calling image would 
> be the same as calling myimage. The former never calls the view. 
>
> Massimo 
>
> On Jan 16, 5:44 am, andrej burja <[email protected]> wrote: 
> > this works 
> > controller: 
> > def image(): 
> >     return dict(a=IMG(_src=URL('myimage'+'.png'))) 
> > view: 
> > {{extend 'layout.html'}} 
> > <h1>This is the graph/image.html template</h1> 
> > {{=a}} 
> > 
> > but this doesn't 
> > controller: 
> > def image(): 
> >     return myimage() 
> > view: 
> > {{extend 'layout.html'}} 
> > <h1>This is the graph/slika1.html template</h1> 
> > {{=IMG(_src=URL('myimage'+'.png'))}}

Reply via email to