block-explorer/webroot/amcharts/plugins/dataloader/dataloader.min.js

1 line
6.6 KiB
JavaScript
Raw Permalink Normal View History

AmCharts.translations.dataLoader={},AmCharts.addInitHandler(function(a){function e(b,d,g,h){void 0===h&&(h="dataProvider"),g.showCurtain&&l(void 0,g.noStyles),c.remaining++,c.percentLoaded[b]=0,void 0!==g.progress&&"function"==typeof g.progress&&void 0===g._progress&&(g._progress=g.progress,g.progress=function(a){c.percentLoaded[b]=a;var d=0,e=0;for(var f in c.percentLoaded)c.percentLoaded.hasOwnProperty(f)&&(e++,d+=c.percentLoaded[f]);var h=Math.round(d/e*100)/100;g._progress.call(this,h,Math.round(100*a)/100,b)}),AmCharts.loadFile(b,g,function(i){if(!1===i)n(g.error,g,a),k(AmCharts.__("Error loading the file",a.language)+": "+b,!1,g);else{switch(void 0===g.format&&(g.format="json"),g.format=g.format.toLowerCase(),g.format){case"json":if(d[h]=AmCharts.parseJSON(i),!1===d[h])return n(g.error,g,a),k(AmCharts.__("Error parsing JSON file",a.language)+": "+c.url,!1,g),void(d[h]=[]);d[h]=f(d[h],g),n(g.load,g,a);break;case"csv":if(d[h]=AmCharts.parseCSV(i,g),!1===d[h])return n(g.error,g,a),k(AmCharts.__("Error parsing CSV file",a.language)+": "+c.url,!1,g),void(d[h]=[]);d[h]=f(d[h],g),n(g.load,g,a);break;default:return n(g.error,g,a),void k(AmCharts.__("Unsupported data format",a.language)+": "+g.format,!1,g.noStyles)}if(c.remaining--,0===c.remaining&&(n(g.complete,a),g.async))if("map"===a.type)a.validateNow(!0),m();else if("gauge"!==a.type&&a.addListener("dataUpdated",function(b){"stock"!==a.type||g.reloading||void 0===a.periodSelector||a.periodSelector.setDefaultPeriod(),m(),a.events.dataUpdated.pop()}),a.validateData(),"gauge"===a.type&&m(),c.startDuration)if("stock"===a.type){a.panelsSettings.startDuration=c.startDuration;for(var j=0;j<a.panels.length;j++)a.panels[j].startDuration=c.startDuration,a.panels[j].animateAgain()}else a.startDuration=c.startDuration,void 0!==a.animateAgain&&a.animateAgain();g.reload&&(g.timeout&&clearTimeout(g.timeout),g.timeout=setTimeout(e,1e3*g.reload,b,d,g,h),g.reloading=!0)}})}function f(b,d){if(void 0===d.postProcess||!h(d.postProcess))return b;try{return d.postProcess.call(c,b,d,a)}catch(e){return k(AmCharts.__("Error loading file",a.language)+": "+d.url,!1,d),b}}function g(a){return"object"==typeof a}function h(a){return"function"==typeof a}function i(a){for(var b in d)d.hasOwnProperty(b)&&j(a,b,d[b])}function j(a,b,c){void 0===a[b]&&(a[b]=c)}function k(a,b,c){c.showErrors?l(a,c.noStyles):(m(),console.log(a))}function l(b,d){m(),void 0===b&&(b=AmCharts.__("Loading data...",a.language));var e=document.createElement("div");if(e.setAttribute("id",a.div.id+"-curtain"),e.className="amcharts-dataloader-curtain",!0!==d){e.style.position="absolute",e.style.top=0,e.style.left=0,e.style.width=(void 0!==a.realWidth?a.realWidth:a.divRealWidth)+"px",e.style.height=(void 0!==a.realHeight?a.realHeight:a.divRealHeight)+"px",e.style.textAlign="center",e.style.display="table",e.style.fontSize="20px";try{e.style.background="rgba(255, 255, 255, 0.3)"}catch(f){e.style.background="rgb(255, 255, 255)"}e.innerHTML='<div style="display: table-cell; vertical-align: middle;">'+b+"</div>"}else e.innerHTML=b;a.containerDiv.appendChild(e),c.curtain=e}function m(){try{void 0!==c.curtain&&a.containerDiv.removeChild(c.curtain)}catch(b){}c.curtain=void 0}function n(a,b,d,e){"function"==typeof a&&a.call(c,b,d,e)}void 0!==a.dataLoader&&g(a.dataLoader)||(a.dataLoader={});var b=a.version.split(".");if(!(Number(b[0])<3||3===Number(b[0])&&Number(b[1])<13)){var c=a.dataLoader;c.remaining=0,c.percentLoaded={};var d={async:!0,format:"json",showErrors:!0,showCurtain:!0,noStyles:!1,reload:0,timestamp:!1,delimiter:",",skip:0,skipEmpty:!0,emptyAs:void 0,useColumnNames:!1,init:!1,progress:!1,reverse:!1,reloading:!1,complete:!1,error:!1,numberFields:[],headers:[],chart:a};c.loadData=function(){if("stock"===a.type)setTimeout(function(){0>a.panelsSettings.startDuration&&(c.startDuration=a.panelsSettings.startDuration,a.panelsSettings.startDuration=0);for(var b=0;b<a.dataSets.length;b++){var d=a.dataSets[b];void 0!==d.dataLoader&&void 0!==d.dataLoader.url&&(n(d.dataLoader.init,d.dataLoader,a),d.dataProvider=[],i(d.dataLoader),e(d.dataLoad