[web2py] Re: D3.js calling Json in View

2014-05-26 Thread thehuman trashcan
Ah right - that makes sense.

Thanks again ;-)

On Saturday, 24 May 2014 03:55:39 UTC+1, Andrew W wrote:

 good work.  data just refers to the dictionary.  When you open up your 
 json file you just see a dictionary with one key that points to an array.
 By saying data.dashboard_data you are then directly referencing the value 
 of the key, ie. the array in the dictionary.  

 There are several ways to do this which I must post to web2pyslices soon, 
 but yours is one of them, and it works !

 web2py with d3 is a good combo.   I plan to do a lot more with the two 
 combined.



 On Friday, May 23, 2014 10:04:17 PM UTC+10, thehuman trashcan wrote:

 In my impatience I just quickly edited the file.  data.dashboard_data is 
 all that was needed.

 I have managed to leave Scheme=true.

 I don't fully understand how data.dashboard_data converts my dictionary 
 to an array, but I will be looking into this to understand.

 In any case, thank you ever so much!


 On Friday, 23 May 2014 05:41:16 UTC+1, Andrew W wrote:

 Also, try scheme='https' in your case. See Core chapter of book.



-- 
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.


[web2py] Re: D3.js calling Json in View

2014-05-23 Thread thehuman trashcan
Thank you so much Andrew - you have given me plenty to work on...

When I'm back I'll give these a go and let you know how I get on.

Many thanks again

On Friday, 23 May 2014 05:41:16 UTC+1, Andrew W wrote:

 Also, try scheme='https' in your case. See Core chapter of book.

-- 
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.


[web2py] Re: D3.js calling Json in View

2014-05-23 Thread thehuman trashcan
In my impatience I just quickly edited the file.  data.dashboard_data is 
all that was needed.

I have managed to leave Scheme=true.

I don't fully understand how data.dashboard_data converts my dictionary to 
an array, but I will be looking into this to understand.

In any case, thank you ever so much!


On Friday, 23 May 2014 05:41:16 UTC+1, Andrew W wrote:

 Also, try scheme='https' in your case. See Core chapter of book.

-- 
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.


[web2py] Re: D3.js calling Json in View

2014-05-22 Thread thehuman trashcan
Hi Andrew,

The URL line now says:

d3.json({{=URL('default', 'dashboard_data.json', scheme=True, host=True)}}
, function (data) {

This doesn't make the information come back though.  Does it matter that I 
am using pythonanywhere - it looks like they have https:// in place?

Thanks!!



On Wednesday, 21 May 2014 11:08:42 UTC+1, Andrew W wrote:

 In the URL() call, add scheme=True, host=True.   

-- 
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.


[web2py] Re: D3.js calling Json in View

2014-05-21 Thread thehuman trashcan
Hi Andrew,

The JSON output is attached (I just grabbed the first 250 lines of some 
public data).

My controller code:

def dashboard_data():
dashboard_data = db().select(db.com_house_stock.CompanyNumber, 
db.com_house_stock.IncorporationDate, db.com_house_stock.CompanyCategory, 
orderby=db.com_house_stock.CompanyNumber)
return dict(dashboard_data=dashboard_data)


def visualisation():
return dict(message=T('Test dashboard'))

And just in case, the visualisation.html code (at the moment I am just 
trying to make the code show a table, with just one column of data, get 
this to work before I move onto anything more complicated!):

{{
  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'}}

h1Open source data dashboard/h1
pPie 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'
thIncDate/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



Thanks for any pointers you can give!!!




On Tuesday, 20 May 2014 17:36:04 UTC+1, Andrew W wrote:

 I use this technique regularly.  Show the controller code and/or json 
 output and I'll have a look.

-- 
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.


dashboard_data.json
Description: Binary data


[web2py] D3.js DC.js Crossfilter.js - table not showing

2014-05-20 Thread thehuman trashcan
Hi,

I am trying to follow the example at: 
https://leanpub.com/D3-Tips-and-Tricks/read#leanpub-auto-crossfilter-dcjs-and-d3js-for-data-discovery

In db.py I have created a database and put in some data

In my controller I created a query, and created a JSON view for the data 
returned (the view is called default/dashboard_data.json)

In a different view, visualisation.html I have written 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'}}

h1Dashboard/h1

div class='container' style='font: 12px sans-serif;'
  div class='row'
div class='span12'
  table  id='dc-table-graph'
thead
  tr class='header'
thIncDate/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('views', '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

The table header returns no problem, but there is no data.  I think maybe 
the problem is with the section which calls the JSON file, I have tried a 
number of different phrases, but nothing changes.

Any help pointing out where I should be looking would be great!!

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.


[web2py] D3.js calling Json in View

2014-05-20 Thread thehuman trashcan
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'}}

h1Open source data dashboard/h1
pPie 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'
thIncDate/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.


[web2py] Re: D3.js calling Json in View

2014-05-20 Thread thehuman trashcan
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'}}

 h1Open source data dashboard/h1
 pPie 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'
 thIncDate/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.


[web2py] Re: Is anyone working on a two-step login for auth? (Sometimes called two factor authentication)

2014-04-29 Thread thehuman trashcan
Thanks for working on this! I think it is important and look forward to 
implementing it.

All the best

On Monday, 28 April 2014 04:10:07 UTC+2, pallav wrote:

 For anyone wondering on the status, my code causes the unit tests for web 
 services to break. I plan on looking into it over the next couple of days.

 On Sunday, April 27, 2014 2:31:37 AM UTC-4, pallav wrote:

 Submitted the pull requests.

 Source: https://github.com/web2py/web2py/pull/431
 Documentation: https://github.com/mdipierro/web2py-book/pull/202

 The two-step verification in this pull can be activated on a per-user 
 basis by adding the user to a group named 'web2py Two-Step Authentication'. 
 This string is hard-coded in the code. If a user logs in successfully with 
 their username and password, and they are a part of this group, then the 
 two-step functionality is enabled. The server sends an email to the user's 
 registered email address with a random code. The user has 4 tries to enter 
 this code before they are logged out and must enter username/password again.

 Possible future enhancements:

- Add some ability to customize. Let people create their own two-step 
auth methods (like the extended_login functionality)
- Add TOTP based two-factor authentication instead of sending email 
(there is already a MOTP plugin for web2py that can be used as base)


 On Wednesday, May 1, 2013 4:36:43 PM UTC-4, Cliff Kachinske wrote:

 If so, can you share the code?

 If not, I will put it on my todo list, but there are a lot of things in 
 front of it.

 Thanks,
 Cliff Kachinske




-- 
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.


[web2py] Re: Best approach to using the DAL with external data sources that will go into multiple tables?

2014-04-09 Thread thehuman trashcan
Hi,

I am totally new to programming, but in a bid to improve, I am trying to 
answer any question I reckon I can add value on..so...!.. 

I would probably define two tables:

*Sources data*
This table details each of your 38 sources and gives them an ID, you can 
give them a name, detail the URL you are using, description, etc.

*Time Series data*
This tables would have 4 columns,
ID (unique ref)
reference ID - this links to the previous table
Date
Amount

This way you can put all the data in this table, and minimise any duplicate 
info.  Maybe put an index in place - not too sure how these work - but I 
think they help speed searching, this might be needed if you have lots of 
values.

Your dashboard can then pull info from the time series data to build the 
graphs yet pull names, source info from the sources data table.

Let me know what you think!


On Tuesday, 8 April 2014 00:53:20 UTC+2, Trent Telfer wrote:

 I am attempting to build a small webpage that takes some pricing data from 
 a few external sources and displays it on one concise page (a dashboard of 
 sorts). My problem is I have 38 timeseries to input in the database and I 
 am hoping someone here can suggest a way around writing multiple 
 define_tables? All data is in the form of dates with one data point, but 
 they don't necessarily all start at the same time.

 Thanks,

 Trent


-- 
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.