Tuesday, 8 April 2014

Getting data from the web...

Ok so I have really made some progress.

I have created a simple cvs file and published it from Google Document as a cvs file.

I have taken this file into my d3 web page and I have generated a simple bar chart with it.

I have also introduced some Javascript alerts which tell me what is happening.


Next step: learn how to do this with a two dimensional array



Google side:

Create a simple spreadsheet.
File...
   Publish to the web....
      Get a link as a csv....

In your d3 file:

d3.text("yourURL",
  function(unparsedData){
  alert(unparsedData)
 
  var data = d3.csv.parseRows(unparsedData);
 
  alert(data)

N.B.

  • unparsed data will be in the form of a list
  • parsed data will be comma separated
  • the alert command brings these onto a Javascript and allows you a look. 
  • it's d3.text rather than d3.csv because you don't have header.



No comments:

Post a Comment