Merger

Merger

realizes an object to merge two or more data sources

Constructor

new Merger()

Source:
This is the Data.Merger class.
It realizes an object to load two or more data sources and merge the data guided by 2 columns with identical values.
Example
var merger = new Data.Merger()
     .addSource(prezzi,{lookup:"idImpianto",columns:["descCarburante","prezzo","isSelf","dtComu"]});
     .addSource(impianti,{lookup:"idImpianto",columns:["Bandiera","Latitudine","Longitudine"]});
		.realize(
	function(mergedTable) {

		selection = mergedTable.select("WHERE tipo_riga == LI");
		 ...
	});
Returns:
a new Data.Merger object

Methods

addSource(source, option)

Source:
add one source to the merger
Examples
.addSource(prezzi,{lookup:"idImpianto",columns:["descCarburante","prezzo","isSelf","dtComu"]});
.addSource(prezzi,{lookup:"idImpianto",columns:["descCarburante","prezzo","isSelf","dtComu"],label:["CARB1","PREZZO","SELF","COM"]});
Parameters:
Name Type Description
source object a loaded data.js table object, typically the result of a data.feed
option object the merging parameter for this sorce: lookup, columns and label [optional]
Returns:
the Data.Merger object

error(onError)

Source:
define error function
Example
var merger= new Data.Merger()
     .addSource("https://raw.githubusercontent.com/ondata/elezionipolitiche2018/master/dati/scrutiniCI_cm.csv","csv")

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

     .realize(
	function() {
         ...
	});
Parameters:
Name Type Description
onError function a user defined function to call when error occurs
Returns:
the Data.Merger object

realize(callback)

Source:
See:
  • Data.Merger.setCallback
initiates the process of merging the sources, guided by the lookup column, inserting all columns that have been defined by .addSource(), or a subset
of them defined by .setOutputColumns()
Example
...
.realize(function(newData){
    ixmaps.setExternalData(newData,{"type":"jsonDB","name":"prezzi_tipo_latlon"});
});	
Parameters:
Name Type Description
callback function user defined function which receives as argument the merged table

setOutputColumns(columnsA)

Source:
define which source columns should be included into the merged table.
Example
var merger = new Data.Merger()
     .addSource(prezzi,{lookup:"idImpianto",columns:["descCarburante","prezzo","isSelf","dtComu"]});
     .addSource(impianti,{lookup:"idImpianto",columns:["Bandiera","Latitudine","Longitudine"]});
		.setOuputColumns(["desCaburante","prezzo"])
     .realize();
Parameters:
Name Type Description
columnsA array a subset of source columns or label you defined by .addSource
Returns:
the Data.Merger object