Wed, 19 Dec 2007

TurboFlot 0.0.1

In an effort to clean up bodhi's metrics code a bit, I wrote a TurboFlot plugin that allows you to wield the jQuery plugin flot inside of TurboGears applications. The code is quite trivial -- it's essentially just a TurboGears JSON proxy to the jQuery flot plugin. Breaking this code out into it's own widget makes it really easy to generate shiny graphs in a Pythonic fashon, without having to write a line of javascript.

Check out the README to see the code for the example above.

To use TurboFlot in your own application, you just pass your data and graph options to the widget, and then throw it up to your template. Read the flot API documentation for details on all of the arguments. Here is a simple usage example:

flot = TurboFlot([
        'data'  : [[0, 3], [4, 8], [8, 5], [9, 13]],
        'lines' : { 'show' : True, 'fill' : True }
        'grid'  : { 'backgroundColor' : '#fffaff' },
        'yaxis' : { 'max' : '850' }
Then, to display the widget in your template, you simply use:

The code for the widget itself is pretty simple. It just takes your data and graph options, encodes them as JSON and tosses them at flot.
class TurboFlot(Widget):
        A TurboGears Flot Widget.
    template = """
      <div xmlns:py="" id="turboflot"
          $.plot($("#turboflot"), ${data}, ${options});
    params = ["data", "options", "height", "width"]
    javascript = [JSLink('turboflot', 'excanvas.js'),
                  JSLink("turboflot", "jquery.js"),
                  JSLink("turboflot", "jquery.flot.js")]

    def __init__(self, data, options={}, height="300px", width="600px"): = simplejson.dumps(data)
        self.options = simplejson.dumps(options)
        self.height = height
        self.width = width

You can download the latest releases from the Python Package Index:
Or you can grab my latest development tree out of mercurial:
As always, patches are welcome :)

posted at: 20:21 | link | Tags: , , , | 5 comments

Posted by belladf at Sun May 8 07:18:27 2011

Credit you - this is sheerest sympathetic ! 
<a href=>&#1500;&#1497;&#1502;&#1493;&#1491;&#1497; &#1504;&#1496;&#1493;&#1512;&#1493;&#1508;&#1514;&#1497;&#1492;</a>

Posted by Inrieqj at Fri Feb 17 22:49:46 2012

Существует такое что <a href=>система продвижения сайта </a> может значительно поднять свой доход в интернете

Posted by Carolina at Sat Nov 16 05:56:51 2013

По моему мнению Вы пошли ошибочным путём.

<a href=><img></img></a>

Posted by Giulia at Fri Dec 5 06:12:43 2014

Thank you for your article. I have the same pelborm with widgets. I have reviewed your source  and wonder if it works  if both  small and big widgets will be placed on screen?