-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvizify.min.js
1 lines (1 loc) · 1.38 KB
/
vizify.min.js
1
var Vizify={chartType:null,libType:null,hooks:[],data:[],chartLoader:{},init:function(o){o=o||{},this.libType=o.library||"",this.chartType=o.type||"",this.hook=o.hook||"","google"===this.libType&&this.loadExt("https://www.google.com/jsapi",this.googleLoadedEvent);var e=this;document.addEventListener("googleLoaded",function(){e.googleLoadedSubscribe()})},googleLoadedEvent:function(){var o=new Event("googleLoaded");document.dispatchEvent(o)},googleLoadedSubscribe:function(){var o=this;this.loadVisualization(function(){o.loadData()})},load:function(o){this.data.push(o.data),this.hooks.push(o.hook)},loadExt:function(o,e){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=o,(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(t),t.onload=function(){e()}},loadVisualization:function(o){var e=this;google.load("visualization","1",{callback:function(){o()},packages:[e.chartType]})},loadData:function(){"google"===this.libType&&"timeline"===this.chartType&&this.renderGoogleTimeline(this.data,this.hooks)},renderGoogleTimeline:function(o,e){for(var t=0;t<o.length;t++){var a=o[t],i=e[t],n=document.querySelector(i),d=new google.visualization.Timeline(n),l=new google.visualization.DataTable;l.addColumn({type:"string",id:a.columnName}),l.addColumn({type:"date",id:"Start"}),l.addColumn({type:"date",id:"End"}),l.addRows(a.rows),d.draw(l)}}};