-
Notifications
You must be signed in to change notification settings - Fork 10
/
d3fire.min.js
executable file
·1 lines (1 loc) · 1.1 KB
/
d3fire.min.js
1
if(!(d3&&d3.version)){throw new Error("D3 not found, be sure to include d3fire after the d3 script tag")}if(!(Firebase&&typeof(Firebase)=="function")){throw new Error("Firebase not found, be sure to include d3fire after the Firebase script tag")}d3.selection.prototype.firebase=function(b,e){if(b&&typeof(b)=="object"){var h=b}else{if(b&&typeof(b)=="string"){var h=new Firebase(b)}else{throw new Error("Invalid firebase parameter")}}if(e.keyFunc&&typeof(e.keyFunc)=="function"){var g=e.keyFunc}else{var g=function(i){return i.name()}}if(e.createFunc&&typeof(e.createFunc)=="function"){var f=e.createFunc}else{var f=function(i){}}if(e.updateFunc&&typeof(e.updateFunc)=="function"){var a=e.updateFunc}else{var a=function(i){}}if(e.deleteFunc&&typeof(e.deleteFunc)=="function"){var c=e.deleteFunc}else{var c=function(i){this.remove()}}var d=this;h.on("child_added",function(i){f.call(d,i).attr("__firekey__",g(i)).datum(i)});h.on("child_changed",function(i){a.call(d.selectAll('[__firekey__="'+g(i)+'"]').datum(i),i)});h.on("child_removed",function(i){c.call(d.selectAll('[__firekey__="'+g(i)+'"]').datum(null),i)});return d};