If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    abraindump  10 years ago

    [Hover Effect Part 2]

    Then using the example controller code from the slice you must specify where the JS files are.  See the references to Config below.  Create the Config object, set the JS locations then pass the Config to the chart. 

    def plot_pygal(): 
        response.headers['Content-Type']='image/svg+xml'
        Config = pygal.Config()
        Config.js = ['https://<IP>:8000/<appname>/static/js/svg.jquery.js',
                     'https://<IP>:8000/<appname>/static/js/pygal-tooltips.js']
        bar_chart = pygal.Bar(Config, 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()
    Now when you display the chart hovering over any bar will display the value.
     

     

Commented on:

Implementing Web2Py+Pygal 2.0. Pygal is a dynamic SVG charting library, It features various graph types: Bar charts, Line charts, XY charts, Pie charts, Radar charts, Dot charts, Pyramid charts, Funnel charts and Gauge charts.

Hosting graciously provided by:
Python Anywhere