Fred,

Somehow it is generating the full _javascript_ you have in the Widget Description (I can not figure out why!?)

 

Here's a modification of my example with the .py file and .kid enclosed:

 

import logging

 

import cherrypy

 

import turbogears

from turbogears import controllers, expose, validate, redirect

from plotkit import PlotKit

from turbogears.widgets import JSSource

from acwebviz import json

 

log = logging.getLogger("acwebviz.controllers")

 

 

class Root(controllers.RootController):

    @expose(template="acwebviz.templates.welcome")

    def index(self):

        import time

        log.debug("Happy TurboGears Controller Responding For Duty")

        return dict(now=time.ctime())

 

   

    @expose(template="acwebviz.templates.plotkit")

    def plotkit(self):

        js = JSSource("""

        // Additional Options

        var options = {

        "IECanvasHTC": "/tg_widgets/plotkit/iecanvas.htc",

        "colorScheme": PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),

        "padding": {left: 0, right: 0, top: 10, bottom: 30},

        "xTicks": [{v:0, label:"ribs"},

              {v:1, label:"toast"},

              {v:2, label:"coffee"},

              {v:3, label:"soup"},

              {v:4, label:"pho"}],

        "drawYAxis": false

        };

      

        function drawGraph() {

            // Layout and Data

            var layout = new PlotKit.Layout("pie", options);

            layout.addDataset("sqrt", [[0, 0], [1, 1], [2, 1.414], [3, 1.73], [4, 2]]);

            layout.evaluate();

 

 

            var data2 = [[0,0], [1,2], [2,3], [3, 7], [4, 8], [5, 6]];

            var plotter2 = EasyPlot("bar", options, $("example"), [data2]);

           

            // Renderer

            //var canvas = MochiKit.DOM.getElement("graph");

            var plotter = new PlotKit.SweetCanvasRenderer($('graph'), layout, options);

            plotter.clear();

            plotter.render();

 

        }

       

 

        MochiKit.DOM.addLoadEvent(drawGraph);

        """)

        plotkit = PlotKit()

        plotkit._javascript_.append(js)

        return dict(plotkit = plotkit)

 

 

and the kid file:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"

    py:extends="'master.kid'">

 

<head>

    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>

    <title>Plotkit</title>

</head>

 

<body>

         <div xmlns:py="http://purl.org/kid/ns#">

            <canvas id="graph" height="300" width="300"></canvas>

 

            <div id="example" style="margin: 0 auto 0 auto;" width="400" height="400"></div>

            </div>

</body>

</html>

 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of gasolin
Sent: Monday, June 19, 2006 11:32 AM
To: TurboGears
Subject: [TurboGears] Re: PlotKit & moo.fx Widget for TurboGears

 

 

 

> Em Segunda 19 Junho 2006 11:31, Brandon Goldfedder escreveu:

> >

>> it is  rendering the _javascript_ for the WidgetDesc example inside of all uses.

> > Had to comment out the Desc class to get things working right...

 

Hi:

 

can you discribe the phenomenon more procisely?

 

such as how you use it?

 

--

Fred

 

 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to