Thanks, your answer inspired me. The solution that works is this:

************

>From the controller file:

points=[[point.thedate.strftime('%Y-%m-%d'), point.value] for point in
pointlist]

************

>From the view file:

<script>
<!--
jQuery(document).ready(function() {
        var p = {{=XML(response.json(points))}}
        $.jqplot('chart1',  [p], {
                title:'Default Date Axis',
                axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}},
                series:[{lineWidth:4, markerOptions:{style:'square'}}]
        });
});
-->
</script>
<div id="chart1" style="margin-top:20px;margin-left:20px; width:200px;
height:200px;">
</div>


On Oct 8, 7:09 pm, DenesL <denes1...@yahoo.ca> wrote:
> try
>
> points=[[point.thedate.strftime('%Y%m%d'), point.value] for point in
> pointlist]
>
> or some other format that suits your needs.
>
> On Oct 8, 10:29 am, Rick <sababa.sab...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi,
> > I want to draw a graph with jqplot, where the x-axis is a date-
> > timeline, but I get this message:
> > TypeError: datetime.date(2011, 10, 2) is not JSON serializable
> > Does anyone know an easy way to pass date variable to json?
>
> > Thanks in advance for help. Here is some code from the files:
>
> > ************
>
> > From the controller file:
> > points=[[point.thedate, point.value] for point in pointlist]
> > return dict(points=points)
>
> > ************
>
> > from the view file:
> > <script>
> > <!--
> > jQuery(document).ready(function() {
> >   $.jqplot('chart1',  [{{=simplejson.dumps(points)}}], {
> >      title:'Default Date Axis',
> >     axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}},
> >     series:[{lineWidth:4, markerOptions:{style:'square'}}]
> >   });});
>
> > -->
> > </script>
> > <div id="chart1" style="margin-top:20px;margin-left:20px; width:200px;
> > height:200px;">
> > </div>

Reply via email to