diff --git a/dataloader.js b/dataloader.js index 43c097d..4757ee1 100644 --- a/dataloader.js +++ b/dataloader.js @@ -2,7 +2,7 @@ Plugin Name: amCharts Data Loader Description: This plugin adds external data loading capabilities to all amCharts libraries. Author: Martynas Majeris, amCharts -Version: 1.0.4 +Version: 1.0.5 Author URI: http://www.amcharts.com/ Copyright 2015 amCharts @@ -172,7 +172,7 @@ AmCharts.addInitHandler( function( chart ) { // error? if ( false === response ) { - callFunction( options.error, url, options ); + callFunction( options.error, options, chart ); raiseError( AmCharts.__( 'Error loading the file', chart.language ) + ': ' + url, false, options ); } else { @@ -193,13 +193,13 @@ AmCharts.addInitHandler( function( chart ) { holder[ providerKey ] = AmCharts.parseJSON( response ); if ( false === holder[ providerKey ] ) { - callFunction( options.error, options ); + callFunction( options.error, options, chart ); raiseError( AmCharts.__( 'Error parsing JSON file', chart.language ) + ': ' + l.url, false, options ); holder[ providerKey ] = []; return; } else { holder[ providerKey ] = postprocess( holder[ providerKey ], options ); - callFunction( options.load, options ); + callFunction( options.load, options, chart ); } break; @@ -209,19 +209,19 @@ AmCharts.addInitHandler( function( chart ) { holder[ providerKey ] = AmCharts.parseCSV( response, options ); if ( false === holder[ providerKey ] ) { - callFunction( options.error, options ); + callFunction( options.error, options, chart ); raiseError( AmCharts.__( 'Error parsing CSV file', chart.language ) + ': ' + l.url, false, options ); holder[ providerKey ] = []; return; } else { holder[ providerKey ] = postprocess( holder[ providerKey ], options ); - callFunction( options.load, options ); + callFunction( options.load, options, chart ); } break; default: - callFunction( options.error, options ); + callFunction( options.error, options, chart ); raiseError( AmCharts.__( 'Unsupported data format', chart.language ) + ': ' + options.format, false, options.noStyles ); return; } @@ -233,7 +233,7 @@ AmCharts.addInitHandler( function( chart ) { if ( 0 === l.remaining ) { // callback - callFunction( options.complete ); + callFunction( options.complete, chart ); // take in the new data if ( options.async ) { @@ -400,9 +400,9 @@ AmCharts.addInitHandler( function( chart ) { /** * Execute callback function */ - function callFunction( func, param1, param2 ) { + function callFunction( func, param1, param2, param3 ) { if ( 'function' === typeof func ) - func.call( l, param1, param2 ); + func.call( l, param1, param2, param3 ); } }, [ 'pie', 'serial', 'xy', 'funnel', 'radar', 'gauge', 'gantt', 'stock', 'map' ] ); diff --git a/dataloader.min.js b/dataloader.min.js index 596bd06..817d89f 100644 --- a/dataloader.min.js +++ b/dataloader.min.js @@ -1 +1 @@ -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++,AmCharts.loadFile(b,g,function(i){if(!1===i)n(g.error,b,g),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),k(AmCharts.__("Error parsing JSON file",a.language)+": "+c.url,!1,g),d[h]=[],void 0;d[h]=f(d[h],g),n(g.load,g);break;case"csv":if(d[h]=AmCharts.parseCSV(i,g),!1===d[h])return n(g.error,g),k(AmCharts.__("Error parsing CSV file",a.language)+": "+c.url,!1,g),d[h]=[],void 0;d[h]=f(d[h],g),n(g.load,g);break;default:return n(g.error,g),k(AmCharts.__("Unsupported data format",a.language)+": "+g.format,!1,g.noStyles),void 0}if(c.remaining--,0===c.remaining){if(n(g.complete),g.async)if("map"===a.type)a.validateNow(!0);else if(a.validateData(),c.startDuration)if("stock"===a.type){a.panelsSettings.startDuration=c.startDuration;for(var j=0;j"):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){"function"==typeof a&&a.call(c,b,d)}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;var d={async:!0,format:"json",showErrors:!0,showCurtain:!0,noStyles:!1,reload:0,timestamp:!1,delimiter:",",skip:0,useColumnNames:!1,reverse:!1,reloading:!1,complete:!1,error:!1};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"):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;var d={async:!0,format:"json",showErrors:!0,showCurtain:!0,noStyles:!1,reload:0,timestamp:!1,delimiter:",",skip:0,useColumnNames:!1,reverse:!1,reloading:!1,complete:!1,error:!1};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