Constructor
new Feed(options)
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 }
|
Returns:
a new Data.Feed object
Methods
error(function(errorText))
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))
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