react-google-charts-with-key
Version:
temporary package as a fix to react-google-charts to add maps apiKey
6 lines • 19.5 kB
JavaScript
/*!
* react-google-charts v1.5.6 - https://rakannimer.github.io/react-google-charts/
* MIT Licensed
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactGoogleCharts=e(require("react")):t.ReactGoogleCharts=e(t.React)}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var o={};return e.m=t,e.c=o,e.i=function(t){return t},e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=15)}([function(t,e,o){(function(n){function r(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(t){var o=this.useColors;if(t[0]=(o?"%c":"")+this.namespace+(o?" %c":" ")+t[0]+(o?"%c ":" ")+"+"+e.humanize(this.diff),o){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(r++,"%c"===t&&(i=r))}),t.splice(i,0,n)}}function a(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(t){}}function u(){var t;try{t=e.storage.debug}catch(t){}return!t&&void 0!==n&&"env"in n&&(t=n.env.DEBUG),t}function c(){try{return window.localStorage}catch(t){}}e=t.exports=o(5),e.log=a,e.formatArgs=i,e.save=s,e.load=u,e.useColors=r,e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:c(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(u())}).call(e,o(10))},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(2);e.default={Chart:n.a}},function(t,e,o){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=o(14),s=o.n(a),u=o(12),c=(o.n(u),o(0)),l=o.n(c),p=o(4),h=o.n(p),d=o(3);o.d(e,"a",function(){return w});var f=new l.a("react-google-charts:Chart"),m=0,g=function(){return"reactgooglegraph-"+(m+=1)},w=function(t){function e(o){n(this,e),f("constructor",o);var i=r(this,t.call(this,o));return i.state={graphID:o.graph_id||g()},i.chart=null,i.wrapper=null,i.hidden_columns={},i.dataTable=[],i.debounce=i.debounce.bind(i),i.onResize=i.onResize.bind(i),i.drawChart=i.drawChart.bind(i),i.togglePoints=i.togglePoints.bind(i),i.buildDataTableFromProps=i.buildDataTableFromProps.bind(i),i.listenToChartEvents=i.listenToChartEvents.bind(i),i.addChartActions=i.addChartActions.bind(i),i.updateDataTable=i.updateDataTable.bind(i),i.onSelectToggle=i.onSelectToggle.bind(i),i.addSourceColumnTo=i.addSourceColumnTo.bind(i),i.restoreColorTo=i.restoreColorTo.bind(i),i.hideColumn=i.hideColumn.bind(i),i}return i(e,t),e.prototype.componentDidMount=function(){var t=this;f("componentDidMount"),"undefined"!=typeof window&&(this.props.loadCharts?(d.a.init(this.props.chartPackages,this.props.chartVersion,this.props.mapsApiKey).then(function(){t.drawChart()}),this.onResize=this.debounce(this.onResize,200),window.addEventListener("resize",this.onResize)):this.drawChart())},e.prototype.componentDidUpdate=function(){var t=this;f("componentDidUpdate"),this.props.loadCharts?d.a.isLoading?d.a.initPromise.then(function(){t.drawChart()}):d.a.isLoaded&&this.drawChart():this.drawChart()},e.prototype.componentWillUnmount=function(){try{window&&(window.google&&window.google.visualization&&window.google.visualization.events.removeAllListeners(this.wrapper),window.removeEventListener("resize",this.onResize))}catch(t){return}},e.prototype.onResize=function(){f("Chart::onResize"),this.drawChart()},e.prototype.onSelectToggle=function(){f("onSelectToggle");var t=this.chart.getSelection();if(t.length>0&&null==t[0].row){var e=t[0].column;this.togglePoints(e)}},e.prototype.getColumnColor=function(t){if(this.props.options.colors){if(this.props.options.colors[t])return this.props.options.colors[t]}else if(t in h.a)return h.a[t];return h.a[0]},e.prototype.buildDataTableFromProps=function(){if(f("buildDataTableFromProps",this.props),this.props.diffdata){var t=this.props.diffdata,e=window.google.visualization.arrayToDataTable(t.old),o=window.google.visualization.arrayToDataTable(t.new);return(0,window.google.visualization[this.props.chartType].prototype.computeDiff)(e,o)}if(null===this.props.data&&0===this.props.rows.length&&!this.props.allowEmptyRows)throw new Error("Can't build DataTable from rows and columns: rows array in props is empty");if(null===this.props.data&&0===this.props.columns.length)throw new Error("Can't build DataTable from rows and columns: columns array in props is empty");if(null!==this.props.data)try{this.wrapper.setDataTable(this.props.data);return this.wrapper.getDataTable()}catch(t){throw new Error("Failed to set DataTable from data props ! ",t)}var n=new window.google.visualization.DataTable;if(this.props.columns.forEach(function(t){n.addColumn(t)}),n.addRows(this.props.rows),this.props.numberFormat){new window.google.visualization.NumberFormat(this.props.numberFormat.options).format(n,this.props.numberFormat.column)}if(this.props.dateFormat){var r=new window.google.visualization.DateFormat(this.props.dateFormat.options);this.props.dateFormat.columns.forEach(function(t){r.format(n,t)})}return n},e.prototype.updateDataTable=function(){return f("updateDataTable"),window.google.visualization.errors.removeAll(document.getElementById(this.wrapper.getContainerId())),this.dataTable.removeRows(0,this.dataTable.getNumberOfRows()),this.dataTable.removeColumns(0,this.dataTable.getNumberOfColumns()),this.dataTable=this.buildDataTableFromProps(),this.dataTable},e.prototype.drawChart=function(){var t=this;if(f("drawChart",this),this.wrapper){if(this.updateDataTable(),this.wrapper.setDataTable(this.dataTable),this.wrapper.setOptions(this.props.options),this.wrapper.getChartType()!==this.props.chartType){window.google.visualization.events.removeAllListeners(this.wrapper),this.wrapper.setChartType(this.props.chartType);var e=this;window.google.visualization.events.addOneTimeListener(this.wrapper,"ready",function(){e.chart=e.wrapper.getChart(),e.listenToChartEvents.call(e)})}}else{var o={chartType:this.props.chartType,options:this.props.options,containerId:this.state.graphID};this.wrapper=new window.google.visualization.ChartWrapper(o),this.dataTable=this.buildDataTableFromProps(),this.wrapper.setDataTable(this.dataTable),window.google.visualization.events.addOneTimeListener(this.wrapper,"ready",function(){t.chart=t.wrapper.getChart(),t.listenToChartEvents(),t.addChartActions()})}this.wrapper.draw()},e.prototype.addChartActions=function(){var t=this;f("addChartActions",this.props.chartActions),null!==this.props.chartActions&&this.props.chartActions.forEach(function(e){t.chart.setAction({id:e.id,text:e.text,action:e.action.bind(t,t.chart)})})},e.prototype.listenToChartEvents=function(){var t=this;f("listenToChartEvents",this.props.legend_toggle,this.props.chartEvents),this.props.legend_toggle&&window.google.visualization.events.addListener(this.wrapper,"select",this.onSelectToggle),this.props.chartEvents.forEach(function(e){"ready"===e.eventName?e.callback(t):function(e){window.google.visualization.events.addListener(t.chart,e.eventName,function(o){e.callback(t,o)})}(e)})},e.prototype.buildColumnFromSourceData=function(t){return f("buildColumnFromSourceData",t),{label:this.dataTable.getColumnLabel(t),type:this.dataTable.getColumnType(t),sourceColumn:t,role:this.dataTable.getColumnRole(t)}},e.prototype.buildEmptyColumnFromSourceData=function(t){return f("buildEmptyColumnFromSourceData",t),{label:this.dataTable.getColumnLabel(t),type:this.dataTable.getColumnType(t),calc:function(){return null},role:this.dataTable.getColumnRole(t)}},e.prototype.addEmptyColumnTo=function(t,e){f("addEmptyColumnTo",t,e);var o=this.buildEmptyColumnFromSourceData(e);t.push(o)},e.prototype.hideColumn=function(t,e){f("hideColumn",t,e),this.isHidden(e)||(this.hidden_columns[e]={color:this.getColumnColor(e-1)}),t.push("#CCCCCC")},e.prototype.addSourceColumnTo=function(t,e){f("addSourceColumnTo",t,e);var o=this.buildColumnFromSourceData(e);t.push(o)},e.prototype.isHidden=function(t){return void 0!==this.hidden_columns[t]},e.prototype.restoreColorTo=function(t,e){f("restoreColorTo",t,e),f("hidden_columns",this.hidden_columns);var o=void 0;this.isHidden(e)?(o=this.hidden_columns[e].color,delete this.hidden_columns[e]):o=this.getColumnColor(e-1),0!==e&&t.push(o)},e.prototype.debounce=function(t,e){var o=void 0;return function(){for(var n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=this;clearTimeout(o),o=setTimeout(function(){return t.apply(a,r)},e)}},e.prototype.togglePoints=function(t){f("togglePoints",t);for(var e=new window.google.visualization.DataView(this.wrapper.getDataTable()),o=e.getNumberOfColumns(),n=[],r=[],i=0;i<o;i+=1)0===i?this.addSourceColumnTo(r,i):i===t?this.isHidden(i)?(this.addSourceColumnTo(r,i),this.restoreColorTo(n,i)):(this.addEmptyColumnTo(r,i),this.hideColumn(n,i)):this.isHidden(i)?(this.addEmptyColumnTo(r,i),this.hideColumn(n,i)):(this.addSourceColumnTo(r,i),this.restoreColorTo(n,i));e.setColumns(r),this.props.options.colors=n,this.chart.draw(e,this.props.options)},e.prototype.render=function(){f("render",this.props,this.state);var t={height:this.props.height||this.props.options.height,width:this.props.width||this.props.options.width};return s.a.createElement("div",{id:this.state.graphID,style:t},this.props.loader?this.props.loader:"Rendering Chart...")},e}(s.a.Component);w.defaultProps={chartType:"LineChart",rows:[],columns:[],options:{chart:{title:"Chart Title",subtitle:"Subtitle"},hAxis:{title:"X Label"},vAxis:{title:"Y Label"},width:"400px",height:"300px"},width:"400px",height:"300px",chartEvents:[],chartActions:null,data:null,legend_toggle:!1,allowEmptyRows:!1,loadCharts:!0,loader:s.a.createElement("div",null,"Rendering Chart"),chartPackages:["corechart"],chartVersion:"current",numberFormat:null,dateFormat:null,diffdata:null}},function(t,e,o){"use strict";var n=o(0),r=o.n(n),i=new r.a("react-google-charts:GoogleChartLoader"),a="undefined"!=typeof window?o(8):function(t,e){return(0,e.success)()},s={isLoaded:!1,isLoading:!1,initPromise:{},init:function(t,e,o){var n=this;return i("init",t,e,o),this.isLoading||this.isLoaded?this.initPromise:(this.isLoading=!0,this.initPromise=new Promise(function(r){a("https://www.gstatic.com/charts/loader.js",{success:function(){var a={packages:t||["corechart"]};o&&(a.mapsApiKey=o),window.google.charts.load(e||"current",a),window.google.charts.setOnLoadCallback(function(){i("Chart Loaded"),n.isLoaded=!0,n.isLoading=!1,r()})}})}),this.initPromise)}};e.a=s},function(t,e){t.exports=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#3B3EAC"]},function(t,e,o){function n(t){var o,n=0;for(o in t)n=(n<<5)-n+t.charCodeAt(o),n|=0;return e.colors[Math.abs(n)%e.colors.length]}function r(t){function o(){if(o.enabled){var t=o,n=+new Date,r=n-(c||n);t.diff=r,t.prev=c,t.curr=n,c=n;for(var i=new Array(arguments.length),a=0;a<i.length;a++)i[a]=arguments[a];i[0]=e.coerce(i[0]),"string"!=typeof i[0]&&i.unshift("%O");var s=0;i[0]=i[0].replace(/%([a-zA-Z%])/g,function(o,n){if("%%"===o)return o;s++;var r=e.formatters[n];if("function"==typeof r){var a=i[s];o=r.call(t,a),i.splice(s,1),s--}return o}),e.formatArgs.call(t,i);(o.log||e.log||console.log.bind(console)).apply(t,i)}}return o.namespace=t,o.enabled=e.enabled(t),o.useColors=e.useColors(),o.color=n(t),"function"==typeof e.init&&e.init(o),o}function i(t){e.save(t),e.names=[],e.skips=[];for(var o=("string"==typeof t?t:"").split(/[\s,]+/),n=o.length,r=0;r<n;r++)o[r]&&(t=o[r].replace(/\*/g,".*?"),"-"===t[0]?e.skips.push(new RegExp("^"+t.substr(1)+"$")):e.names.push(new RegExp("^"+t+"$")))}function a(){e.enable("")}function s(t){var o,n;for(o=0,n=e.skips.length;o<n;o++)if(e.skips[o].test(t))return!1;for(o=0,n=e.names.length;o<n;o++)if(e.names[o].test(t))return!0;return!1}function u(t){return t instanceof Error?t.stack||t.message:t}e=t.exports=r.debug=r.default=r,e.coerce=u,e.disable=a,e.enable=i,e.enabled=s,e.humanize=o(9),e.names=[],e.skips=[],e.formatters={};var c},function(t,e,o){"use strict";function n(t){return function(){return t}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(t){return t},t.exports=r},function(t,e,o){"use strict";function n(t,e,o,n,i,a,s,u){if(r(e),!t){var c;if(void 0===e)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[o,n,i,a,s,u],p=0;c=new Error(e.replace(/%s/g,function(){return l[p++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var r=function(t){};t.exports=n},function(t,e,o){var n,r,i;!function(o,a){r=[],n=a,void 0!==(i="function"==typeof n?n.apply(e,r):n)&&(t.exports=i)}(0,function(){function t(t,e){t=t.push?t:[t];var o,n,r,i,a=[],c=t.length,l=c;for(o=function(t,o){o.length&&a.push(t),--l||e(a)};c--;)n=t[c],r=s[n],r?o(n,r):(i=u[n]=u[n]||[],i.push(o))}function e(t,e){if(t){var o=u[t];if(s[t]=e,o)for(;o.length;)o[0](t,e),o.splice(0,1)}}function o(t,e,n,r){var a,s,u=document,c=n.async,l=(n.numRetries||0)+1,p=n.before||i;r=r||0,/(^css!|\.css$)/.test(t)?(a=!0,s=u.createElement("link"),s.rel="stylesheet",s.href=t.replace(/^css!/,"")):(s=u.createElement("script"),s.src=t,s.async=void 0===c||c),s.onload=s.onerror=s.onbeforeload=function(i){var u=i.type[0];if(a&&"hideFocus"in s)try{s.sheet.cssText.length||(u="e")}catch(t){u="e"}if("e"==u&&(r+=1)<l)return o(t,e,n,r);e(t,u,i.defaultPrevented)},!1!==p(t,s)&&u.head.appendChild(s)}function n(t,e,n){t=t.push?t:[t];var r,i,a=t.length,s=a,u=[];for(r=function(t,o,n){if("e"==o&&u.push(t),"b"==o){if(!n)return;u.push(t)}--a||e(u)},i=0;i<s;i++)o(t[i],r,n)}function r(t,o,r){var s,u;if(o&&o.trim&&(s=o),u=(s?r:o)||{},s){if(s in a)throw"LoadJS";a[s]=!0}n(t,function(t){t.length?(u.error||i)(t):(u.success||i)(),e(s,t)},u)}var i=function(){},a={},s={},u={};return r.ready=function(e,o){return t(e,function(t){t.length?(o.error||i)(t):(o.success||i)()}),r},r.done=function(t){e(t,[])},r.reset=function(){a={},s={},u={}},r.isDefined=function(t){return t in a},r})},function(t,e){function o(t){if(t=String(t),!(t.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var o=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return o*l;case"days":case"day":case"d":return o*c;case"hours":case"hour":case"hrs":case"hr":case"h":return o*u;case"minutes":case"minute":case"mins":case"min":case"m":return o*s;case"seconds":case"second":case"secs":case"sec":case"s":return o*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}}}function n(t){return t>=c?Math.round(t/c)+"d":t>=u?Math.round(t/u)+"h":t>=s?Math.round(t/s)+"m":t>=a?Math.round(t/a)+"s":t+"ms"}function r(t){return i(t,c,"day")||i(t,u,"hour")||i(t,s,"minute")||i(t,a,"second")||t+" ms"}function i(t,e,o){if(!(t<e))return t<1.5*e?Math.floor(t/e)+" "+o:Math.ceil(t/e)+" "+o+"s"}var a=1e3,s=60*a,u=60*s,c=24*u,l=365.25*c;t.exports=function(t,e){e=e||{};var i=typeof t;if("string"===i&&t.length>0)return o(t);if("number"===i&&!1===isNaN(t))return e.long?r(t):n(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e){function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function r(t){if(l===setTimeout)return setTimeout(t,0);if((l===o||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function i(t){if(p===clearTimeout)return clearTimeout(t);if((p===n||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(t);try{return p(t)}catch(e){try{return p.call(null,t)}catch(e){return p.call(this,t)}}}function a(){m&&d&&(m=!1,d.length?f=d.concat(f):g=-1,f.length&&s())}function s(){if(!m){var t=r(a);m=!0;for(var e=f.length;e;){for(d=f,f=[];++g<e;)d&&d[g].run();g=-1,e=f.length}d=null,m=!1,i(t)}}function u(t,e){this.fun=t,this.array=e}function c(){}var l,p,h=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:o}catch(t){l=o}try{p="function"==typeof clearTimeout?clearTimeout:n}catch(t){p=n}}();var d,f=[],m=!1,g=-1;h.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)e[o-1]=arguments[o];f.push(new u(t,e)),1!==f.length||m||r(s)},u.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=c,h.addListener=c,h.once=c,h.off=c,h.removeListener=c,h.removeAllListeners=c,h.emit=c,h.prependListener=c,h.prependOnceListener=c,h.listeners=function(t){return[]},h.binding=function(t){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(t){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(t,e,o){"use strict";var n=o(6),r=o(7),i=o(13);t.exports=function(){function t(t,e,o,n,a,s){s!==i&&r(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function e(){return t}t.isRequired=t;var o={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e};return o.checkPropTypes=n,o.PropTypes=o,o}},function(t,e,o){t.exports=o(11)()},function(t,e,o){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,o){e.exports=t},function(t,e,o){t.exports=o(1)}])});
//# sourceMappingURL=react-google-charts.min.js.map