In your javascript console type d3
Do you get something?
Try this
download d3 and nvd3 files to your app static folder.
then change your code to this
{{response.files.extend([URL('static','js/d3.v2.js')])}}
{{extend 'layout.html'}}
2013/5/3 FERNANDO VILLARROEL <[email protected]>
> Dear.
>
> I am trying to make a graph temperature vs time with NVD3.js
>
> But it's my first experience with D3 and JsON and i think i am wrong
> because i can't show graphic.
>
> I am getting data from a database:
>
> My controller:
>
> def grafico_temp():
>
>
> rows=db(db.temperaturas).select(db.temperaturas.fecha,db.temperaturas.temp).as_list()
> return dict(rows=rows)
>
> My view:
>
> {{extend 'layout.html'}}
>
> <link href="https://raw.github.com/novus/nvd3/master/src/nv.d3.css"
> rel="stylesheet"/>
> <script type="text/javascript" src="
> https://raw.github.com/novus/nvd3/master/lib/d3.v2.min.js"></script>
> <script type="text/javascript" src="
> https://raw.github.com/novus/nvd3/master/nv.d3.min.js"></script>
>
> <style>
> #chart svg {
> height: 400px;
> }
> </style>
>
> <div id="chart">
> <svg></svg>
> </div>
>
>
>
> <script type="text/javascript">
>
> nv.addGraph(function() {
> var chart = nv.models.lineChart();
>
> chart.xAxis
> .axisLabel('Fecha')
> .tickFormat(d3.format(',r'));
>
> chart.yAxis
> .axisLabel('Temperatura')
> .tickFormat(d3.format('.02f'));
>
> d3.select('#chart svg')
> .datum(data())
> .transition().duration(500)
> .call(chart);
>
> nv.utils.windowResize(function() { d3.select('#chart
> svg').call(chart) });
>
> return chart;
> });
>
>
>
> function data() {
>
> var camara1 = {{=response.json(rows)}} //[];
> //var t = {{=len(rows)}};
> //{{for r in rows:}}
> // var f = {{r.fecha}}, t = {{r.temp}};
> //for (var i = 0; i <= t; i++) {
> // camara1.push({x: f, y: t});
> //cos.push({x: i, y: .5 * Math.cos(i/10)});
> //{{pass}}
> }
>
> return [
> {
> values: camara1,
> key: 'Camara 1'
> color: '#ff7f0e'
> },
> ];
> }
> </script>
>
>
> I appreciated you help.
>
> --- On Thu, 8/16/12, Andrew <[email protected]> wrote:
>
> > From: Andrew <[email protected]>
> > Subject: Re: [web2py] Graphs
> > To: [email protected]
> > Date: Thursday, August 16, 2012, 7:41 AM
> > I plan to do one, but you simply
> > provide a json or csv service / URL with web2py, and then
> > use it in a view with the d3 JavaScript code. D3 takes
> > some learning, and I still have a long way to go.
> >
> > --
> >
> >
> >
> >
>
> --
>
> ---
> 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/groups/opt_out.
>
>
>
--
---
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/groups/opt_out.