-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathvue-charts.min.js
More file actions
6 lines (6 loc) · 3.72 KB
/
vue-charts.min.js
File metadata and controls
6 lines (6 loc) · 3.72 KB
1
2
3
4
5
6
/*!
* vue-charts v0.2.1
* (c) 2016 Hayden Bickerton
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],t):e.VueCharts=t(e._)}(this,function(e){"use strict";function t(){var e=null,t=null,a=new Promise(function(a,r){e=a,t=r});return{promise:a,resolve:e,reject:t}}function a(e,t,a){for(var r in a){var n=r,i=a[r];"ready"===n?i():google.visualization.events.addListener(t,n,i)}}function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["corechart"],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"current",a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"en";if(!Array.isArray(e))throw new TypeError("packages must be an array");if("current"!==t&&"number"!=typeof t&&"upcoming"!==t)throw new TypeError('version must be a number, "upcoming" or "current"');if(o||u)return s.promise;o=!0;var n=document.createElement("script");return n.setAttribute("src","https://www.gstatic.com/charts/loader.js"),n.onreadystatechange=n.onload=function(){var n={packages:e,language:r};a&&(n.mapsApiKey=a),google.charts.load(t,n),google.charts.setOnLoadCallback(function(){o=!1,u=!0,s.resolve()})},document.getElementsByTagName("head")[0].appendChild(n),s.promise}function n(t,a){e.each(a,function(a,r){var n=a.type;t.$watch(r,function(){t.drawChart()},{deep:e.isObject(n)})})}function i(e){arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.component("vue-chart",d)}e="default"in e?e.default:e;var o=!1,u=!1,s=t(),c=t(),l={packages:{type:Array,default:function(){return["corechart"]}},version:{default:"current"},mapsApiKey:{default:!1},language:{type:String,default:"en"},chartType:{type:String,default:function(){return"LineChart"}},chartEvents:{type:Object,default:function(){return{}}},columns:{required:!0,type:Array},rows:{type:Array,default:function(){return[]}},options:{type:Object,default:function(){return{chart:{title:"Chart Title",subtitle:"Subtitle"},hAxis:{title:"X Label"},vAxis:{title:"Y Label"},width:"400px",height:"300px",animation:{duration:500,easing:"out"}}}}},d={name:"vue-chart",props:l,render:function(e){var t=this;return e("div",{class:"vue-chart-container"},[e("div",{attrs:{id:t.chartId,class:"vue-chart"}})])},data:function(){return{chart:null,chartId:"X"+this._uid,wrapper:null,dataTable:[],hiddenColumns:[]}},events:{redrawChart:function(){this.drawChart()}},mounted:function(){var e=this;r(e.packages,e.version,e.mapsApiKey,e.language).then(e.drawChart).then(function(){var t=l;delete t.bounds,n(e,t),a(e,e.chart,e.chartEvents)}).catch(function(e){throw e})},methods:{buildDataTable:function(){var t=this,a=new google.visualization.DataTable;return e.each(t.columns,function(e){a.addColumn(e)}),e.isEmpty(t.rows)||a.addRows(t.rows),a},updateDataTable:function(){var t=this;t.dataTable.removeRows(0,t.dataTable.getNumberOfRows()),t.dataTable.removeColumns(0,t.dataTable.getNumberOfColumns()),e.each(t.columns,function(e){t.dataTable.addColumn(e)}),e.isEmpty(t.rows)||t.dataTable.addRows(t.rows)},buildWrapper:function(e,t,a,r){var n=new google.visualization.ChartWrapper({chartType:e,dataTable:t,options:a,containerId:r});return n},buildChart:function(){var t=this,a=e.isEmpty(t.dataTable)?t.buildDataTable():t.dataTable;t.wrapper=t.buildWrapper(t.chartType,a,t.options,t.chartId),t.dataTable=t.wrapper.getDataTable(),google.visualization.events.addOneTimeListener(t.wrapper,"ready",function(){t.chart=t.wrapper.getChart(),c.resolve()})},drawChart:function(){var t=this;if((e.isEmpty(t.rows)||e.isObjectLike(t.rows))&&!e.isEmpty(t.columns))return e.isNull(t.chart)?t.buildChart():t.updateDataTable(),t.wrapper.draw(),c.promise}}};return i});