Anthony, thanks! I will give the @service.csv method a try.
On Monday, June 24, 2013 3:12:15 PM UTC-5, Anthony wrote: > > Do you want to embed the data in the page, or do you want to serve it as a > CSV file? If you want to embed it in the page, you might need to embed it > in some Javascript as a Javascript data structure rather than as pure HTML. > To serve a CSV file, see http://web2py.com/books/default/chapter/29/10#CSV > (you > might be able to set the content type to 'text/csv' rather than what is > shown in that example). You would then provide D3 with the URL that serves > the CSV file (note, it doesn't actually generate a CSV file on the server > -- it just uses a cStringIO object and sends its content as the HTTP > response). > > Anthony > > On Monday, June 24, 2013 4:02:35 PM UTC-4, greaneym wrote: >> >> Relating to d3.js and csv files, I'm having two problems trying to get a >> string object to load either >> >> 1. with d3.csv.parse or with >> >> 2. function() {return x; } >> >> right after the line, >> g = new Dygraph( document.getElementById("div_pt"), >> >> that begins to generate a d3 graph. >> >> >> The problem is similar to that on >> http://stackoverflow.com/questions/14286461/django-and-d3-js-csv-data >> >> but I don't understand how to make the url "have a text content". >> >> Also, I am having a problem understanding what it means to use >> the >> function() return x >> >> as the method to return data to d3.js. I want to load a string value into >> x >> and have the graph display. When I use that and feed it {{=pt_data}} it >> looks like the view source output at the bottom of this page. >> >> I am able to load a .csv file and produce a graph, but when I try to >> create a string that can be loaded into function() {return x;} and it is >> formatted as a csv >> file, the graph doesn't load. >> (disregard he timevalues). >> >> >> The error console on the web inspector says, >> syntax error, unexpected number, '00' >> which means it is not parsing the date+time together. >> >> Does the string have to be formatted differently from the CSV file? They >> look the same to me. How should the pt_data format in the browser's >> 'view/source' look when it works? >> >> For reference, I read the docs files in dygraphs-master docs/data.html as >> well as many other d3.js tutorials, but so far have not found an answer. >> This project will also use json objects, but before that I want to get >> the csv as string object working first. >> >> >> <!DOCTYPE html> >> <html> >> <head> >> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; >> IE=EmulateIE9"> >> <title>Summary</title> >> <!--[if IE]> >> <script type="text/javascript" >> src="../../static/dygraphjs/excanvas.js"></script> >> <![endif]--> >> >> <script src="/enp8/static/dygraphjs/dygraph-dev.js" >> type="text/javascript"></script> >> <script src="/enp8/static/dygraphjs/d3.v3.js" >> type="text/javascript"></script> >> >> </head> >> <body> >> <h6>pt_data is Date,ENWH >> 2011/09/10 00:05,0 >> 2011/09/10 00:05,0 >> 2011/09/10 00:05,0 >> 2011/09/10 00:05,0 >> 2011/09/10 00:05,32 >> 2011/09/10 00:05,246 >> 2011/09/10 00:05,250 >> 2011/09/10 00:05,424 >> 2011/09/10 00:05,500 >> 2011/09/10 00:05,678 >> 2011/09/10 00:05,898 >> 2011/09/10 00:05,525 >> 2011/09/10 00:05,400 >> 2011/09/10 00:05,379 >> 2011/09/10 00:05,184 >> 2011/09/10 00:05,41 >> 2011/09/10 00:05,0 >> 2011/09/10 00:05,0 >> 2011/09/10 00:05,0 >> 2011/09/10 00:05,0 </h6> >> <p>Power Today Data:</p> >> <div id="div_pt" style="width:600px; height:300px;"></div> >> <script type="text/javascript"> >> g = new Dygraph( document.getElementById("div_pt"), >> d3.csv.parse(=URL('power_today', 'index')}} ; } >> { } >> ); >> >> >> </script> >> >> <!--<table width="100%">--> >> <table width="75%"> >> <tr> >> <h2>Summary 2011-09-10 </h2> >> <td><h5><ul>Intervals:</h5></ul> 300</h5></td> >> <td><h5><ul>Power (W):</h5></ul> [0, 0, 0, 0, 32, 246, 250, 424, 500, >> 678, 898, 525, 400, 379, 184, 41, 0, 0, 0, 0]</h5></td> >> </tr> >> <br> >> <br> >> >> </table> >> >> <h5> JSON data formatted via python</h5> >> {u'first_interval_end_date': >> u'2011-09-10T00:05-7:00', u'production': [0, 0, 0, 0, >> 32, 246, 250, 424, 500, 678, 898, 525, 400, 379, 184, 41, 0, 0, 0, 0], >> u'interval_length': 300} >> >> >> >> </body> >> </html> >> >> >> >> Thanks a lot for any help or suggestions. >> >> Margaret >> >> -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.