I found something :

In a controller (the import is done in a model) :

def mychart():
    return dict(a=IMG(_src=URL('draw'+'.png')))

def draw():
    x = [datetime.date(2014, 1, 29), datetime.date(2014, 4, 15), 
datetime.date(2014, 3, 29)]
    y = [2, 4, 1]

    fig, ax = plt.subplots()
    ax.plot_date(x, y, markerfacecolor='CornflowerBlue', 
markeredgecolor='white')
    fig.autofmt_xdate()
    ax.set_xlim([datetime.date(2014, 1, 26), datetime.date(2014, 5, 1)])
    ax.set_ylim([0, 5])
    body = cStringIO.StringIO()
    plt.savefig(body)
    return body.getvalue()

View:
{{=a}}

Now how to run this code if put the function draw in a model (as done in 
the examples given)

thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to