webpackJsonp([8],{"0Y4C":function(t,a,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var r=e("fZjL"),i=e.n(r),s=(e("UlOv"),{name:"pie",props:["chartData","options","width","height"],watch:{chartData:function(){this.myChart?this.myChart.update():this.myChart=new Chart(this.$refs.chart.getContext("2d"),{type:"pie",data:this.chartData,options:this.options})}},data:function(){return{myChart:null}},mounted:function(){this.chartData&&(this.myChart=new Chart(this.$refs.chart.getContext("2d"),{type:"pie",data:this.chartData,options:this.options}))},methods:{updateChart:function(){this.myChart.update()}}}),n={render:function(){var t=this.$createElement,a=this._self._c||t;return a("div",[a("canvas",{ref:"chart",staticStyle:{margin:"auto"},attrs:{height:this.height}})])},staticRenderFns:[]};var o={created:function(){},data:function(){return{_seed:"",pieData:null,pieOptions:{responsive:!0},chartColors:{red:"rgb(255, 99, 132)",orange:"rgb(255, 159, 64)",yellow:"rgb(255, 205, 86)",green:"rgb(75, 192, 192)",blue:"rgb(54, 162, 235)",purple:"rgb(153, 102, 255)",grey:"rgb(201, 203, 207)"},MONTHS:["January","February","March","April","May","June","July","August","September","October","November","December"]}},mounted:function(){this.updateChart()},methods:{updateChart:function(){this._seed=Date.now(),this.pieData={datasets:[{data:[this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor()],backgroundColor:[this.chartColors.red,this.chartColors.orange,this.chartColors.yellow,this.chartColors.green,this.chartColors.blue],label:"数据集1"}],labels:["Red","Orange","Yellow","Green","Blue"]}},randomScalingFactor:function(){return Math.round(100*Math.random())},randNum:function(t,a){var e=this._seed;return t=void 0===t?0:t,a=void 0===a?1:a,this._seed=(9301*e+49297)%233280,t+this._seed/233280*(a-t)},randomizeData:function(){var t=this,a=this.pieData;a.datasets.forEach(function(e,r){var i=e;i.data.forEach(function(a,e){i.data[e]=t.randomScalingFactor()}),a.datasets[r]=i}),this.pieData=a,this.$refs.pie.updateChart()},addDataset:function(){for(var t=i()(this.chartColors),a={backgroundColor:[],data:[],label:"新数据集"+this.pieData.datasets.length},e=0;e<this.pieData.labels.length;++e){a.data.push(this.randomScalingFactor());var r=t[e%t.length],s=this.chartColors[r];a.backgroundColor.push(s)}this.pieData.datasets.push(a),this.$refs.pie.updateChart()},removeDataset:function(){this.pieData.datasets.splice(0,1),this.$refs.pie.updateChart()},addData:function(){var t=this;if(this.pieData.datasets.length>0){var a=this.MONTHS[this.pieData.labels.length%this.MONTHS.length];this.pieData.labels.push(a),this.pieData.datasets.forEach(function(a){a.data.push(t.randomScalingFactor())}),this.$refs.pie.updateChart()}},removeData:function(){this.pieData.labels.splice(-1,1),this.pieData.datasets.forEach(function(t){t.data.pop()}),this.$refs.pie.updateChart()}},components:{pieChart:e("VU/8")(s,n,!1,function(t){e("r7p/")},"data-v-a01dca72",null).exports}},h={render:function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",[e("pie-chart",{ref:"pie",staticStyle:{"max-width":"1000px",margin:"auto"},attrs:{height:150,chartData:t.pieData,options:t.pieOptions}}),t._v(" "),e("el-row",{staticStyle:{"margin-top":"50px"},attrs:{type:"flex",justify:"center"}},[e("el-button",{on:{click:t.randomizeData}},[t._v("随机改变值")]),t._v(" "),e("el-button",{attrs:{type:"primary"},on:{click:t.addDataset}},[t._v("添加数据集")]),t._v(" "),e("el-button",{attrs:{type:"success"},on:{click:t.removeDataset}},[t._v("删除数据集")])],1)],1)},staticRenderFns:[]};var c=e("VU/8")(o,h,!1,function(t){e("GSV1")},"data-v-6c9f47ff",null);a.default=c.exports},GSV1:function(t,a){},"r7p/":function(t,a){}});
//# sourceMappingURL=8.4ca3135a49327c23d14f.js.map