Feed

Feed

It realizes an object to load and handle one data sources

Constructor

new Feed(options)

Source:
Create a new Data.Feed instance.
Example
var szUrl = "https://raw.githubusercontent.com/emergenzeHack/terremotocentro/master/_data/issues.csv";
var myfeed = new Data.Feed("Segnalazioni",{"source":szUrl,"type":"csv"}).load(function(mydata){
	
   // when the feed is loaded, it calls the function you defined
   // with the loaded data as argument; it is a Table object, so you can use its methods
   // example: create new columns 'date' and 'hour' from one timestamp column
   // ---------------------------------------------------------------
   mydata = mydata.addColumn({'source':'created_at','destination':'date'},
       function(value){
           var d = new Date(__normalizeTime(value));
           return( String(d.getDate()) + "." + String(d.getMonth()+1) + "." + String(d.getFullYear()) );
    });
 });

 // Note: instead of new Data.Feed() you can also use the factory function Data.feed()
 var myfeed = Data.feed("Segnalazioni",{"source":szUrl,"type":"csv"}).load(function(mydata){
 ...
    
Parameters:
Name Type Description
options Object

{ source: url or filename, type: see table below }

typedescription
"csv"the source is 'plain text' formatted as Comma Separated Values
delimiter supported: , and ;
"json"the source is JSON (Javascript Object Notation)
"JSON-stat"the source is a JSON object formatted in JSON-stat
"jsonDB"the source is in ixmaps internal data table format
"rss"the source is an xml rss feed
Returns:
a new Data.Feed object

Methods

error(function(errorText))

Source:
define a function to handle a loading error
Example
var myfeed = Data.feed("Segnalazioni",{"source":szUrl,"type":"csv"})

             .error(function(e){alert(e);})

             .load(function(mydata){
	               ...
             });
Parameters:
Name Type Description
function(errorText) function a user defined function to call when an error occurs
Returns:
the Data.Feed object

load(function(data))

Source:
load the data from the source specified in the Data.Feed instance and call a user defined callback function on success
Example
var szUrl = "https://raw.githubusercontent.com/emergenzeHack/terremotocentro/master/_data/issues.csv";
var myfeed = Data.feed({"source":szUrl,"type":"csv"}).load(function(mydata){
	...
 });
Parameters:
Name Type Description
function(data) function the function to call when data is successfully loaded
it receives a Data.Table object with the loaded data
Returns:
the Data.Feed object