Thanks Anthony,

When I manually load the JSON file I do see the correct data.  The Network 
activity (I am using Chrome) seems to show that it pulled the JSON file 
back ok.  

But I cannot see an Ajax request?? I do see that the D3.JS returns with a 
304 status, NOT MODIFIED.  Thanks for your suggestion I guess maybe there 
is something wrong with the D3 code...



On Tuesday, 20 May 2014 14:44:25 UTC+1, Anthony wrote:
>
> When you manually go to /yourapp/default/dashboard_data.json, do you get 
> the JSON you expect? If so, when you load the page in question, if you 
> watch the network activity in the browser developer tools, do you see an 
> Ajax request successfully pulling in that JSON? If all that works, then the 
> problem must be either with the format of the JSON or with your D3 code.
>
> Anthony
>
> On Tuesday, May 20, 2014 9:08:34 AM UTC-4, thehuman trashcan wrote:
>>
>> Hi,
>>
>> I am following the instructions at: 
>> https://leanpub.com/D3-Tips-and-Tricks/read#leanpub-auto-crossfilter-dcjs-and-d3js-for-data-discoveryand
>>  trying to put this into web2py.
>>
>> I created the database in the db.py, populated it with some data.
>> I have created a controller which queries the database, and created a 
>> JSON view (default/dashboard_data.json) pulling this data back.
>>
>> I have a view (visualisation.html) with the following code:
>>
>> {{
>>   response.files.append(URL('static','js/d3.js'))
>>   response.files.append(URL('static','js/crossfilter.js'))
>>   response.files.append(URL('static','js/dc.js'))
>> }}
>> {{extend 'layout.html'}}
>>
>> <h1>Open source data dashboard</h1>
>> <p>Pie chart displaying percentages of each category in the database</p>
>>
>> <div class='container' style='font: 12px sans-serif;'>
>>   <div class='row'>
>>     <div class='span12'>
>>       <table  id='dc-table-graph'>
>>         <thead>
>>           <tr class='header'>
>>             <th>IncDate</th>
>>           </tr>
>>         </thead>
>>       </table>
>>     </div>
>>   </div>
>> </div>
>>
>> <script>
>> {{# create dc.js chart object & link to DIV}}
>>     var dataTable = dc.dataTable("#dc-table-graph");
>>
>> {{# load data}}
>> d3.json("{{=URL('default', 'dashboard_data.json')}}", function (data) {
>>     
>>     {{# format data}}
>>       var dtgFormat = d3.time.format("%d/%m/%Y");
>>     
>>       data.forEach(function (d) {
>>           d.incdate = dtgFormat.parse(d.IncorporationDate);
>>       });
>>
>>     {{# run data through crossfilter}}
>>       var facts = crossfilter(data);
>>       
>>       {{# Create dataTable dimension}}
>>       var timeDimension = facts.dimension(function (d) {
>>         return d.incdate;
>>       });
>>
>>  dataTable.width(960).height(800)
>>     .dimension(timeDimension)
>> .group(function(d) { return "Table"
>>  })
>> .size(10)
>>     .columns([
>>       function(d) { return d.incdate; }
>>     ])
>>     .sortBy(function(d){ return d.incdate; })
>>     .order(d3.ascending);
>>
>>         dc.renderAll ();
>>        });
>>         
>> </script>
>>
>>
>>
>> I think the problem is with referencing the JSON file in the URL, but I 
>> don't seem to be able to find the correct method of doing this in the book. 
>>  If that's not the problem, then I really have no idea where to begin!
>>
>> If anyone could help at all, I would really appreciate it.
>>
>> Many thanks
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to