Hi

Try separate function for form & chart and in the view/form.html you can 
use function {{ =LOAD('chart', ...) }}

or

You can embedded python chart code into form.html for example:
{{
   import pygal
   from pygal.style import DefaultStyle
   from pygal import Config
   config = Config()
   config.human_readable = True

   line_chart = pygal.Line(title = 'COMPANY',
        x_labels = map(lambda d: d.strftime('%Y-%m-%d'), [each_day[0] for 
each_day in daily_sales_each_day]),
        x_label_rotation = 20,
                           dots_size = 5,
                           title_font_size = 20,
                           label_font_size = 10,
                           legend_font_size = 10,
                           value_font_size = 10,
                           legend_at_bottom = True,
                           tooltip_font_size = 14,
                           value_formatter  = lambda ml: 
'{:,.2f}'.format(ml),
                           style = DefaultStyle)

line_chart.add('Sales Order', [each_day[1][0][1] or 0 for each_day in 
daily_sales_each_day])
   =TAG(line_chart.render())
   }}

hope it help.
Ariya

เมื่อ วันพุธที่ 20 มกราคม ค.ศ. 2016 20 นาฬิกา 47 นาที 16 วินาที UTC+7, 
[email protected] เขียนว่า:
>
> Hi Guys, 
>
> I try to use pygal to draw some charts and it works fine. I used example 
> from:
>
>
> http://www.web2pyslices.com/slice/show/1634/beauty-graphics-and-charts-with-pygal
>
> However i don't know how to display SQL.form and pygal chart in one view.
>
> My code 
>
>
> def form_and_chart():
>      chart = plot_pygal()
>      form = SQLFORM.factory( Field('time') )
>      return dict(form=form),chart
>
>
> def plot_pygal():
>  response.headers['Content-Type']='image/svg+xml'
>  bar_chart = pygal.Bar(style=CleanStyle) # Then create a bar graph object
>  bar_chart.add('Fibonacci', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) # Add 
> some values 
>  return bar_chart.render()
>
>
> view: form_and_chart.html
>
> {{extend 'layout.html'}}
> {{=form}}
> <embed src="http://localhost/myapp/default/plot_pygal.svg"; type=
> "image/svg+xml" />
>
>
> When i do return(form=form), form is displayed correctly, when i do return 
> chart, chart is displayed correctly. How to combine those two to be 
> displayed on one page?
>
> Thanks!
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to