webpackJsonp([11],{G08K:function(t,a){},W7rb:function(t,a,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var r=e("fZjL"),n=e.n(r),i=(e("UlOv"),{name:"bar",props:["chartData","options","width","height"],watch:{chartData:function(){this.myChart?this.myChart.update():this.myChart=new Chart(this.$refs.chart.getContext("2d"),{type:"bar",data:this.chartData,options:this.options})}},data:function(){return{myChart:null}},mounted:function(){console.log(this.type),this.chartData&&(this.myChart=new Chart(this.$refs.chart.getContext("2d"),{type:"bar",data:this.chartData,options:this.options}))},methods:{updateChart:function(){this.myChart.update()}}}),s={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:"",lineData:null,lineOptions:{responsive:!0,title:{display:!0,text:"柱状图"},tooltips:{mode:"index",intersect:!1},hover:{mode:"nearest",intersect:!0},scales:{xAxes:[{display:!0,scaleLabel:{display:!0,labelString:"Month"}}],yAxes:[{display:!0,scaleLabel:{display:!0,labelString:"Value"}}]}},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.type=this.$route.query.type,this._seed=Date.now(),this.lineData={labels:["January","February","March","April","May","June","July"],datasets:[{label:"第1项",backgroundColor:this.chartColors.red,borderColor:this.chartColors.red,data:[this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor()],fill:!1},{label:"第2项",fill:!1,backgroundColor:this.chartColors.blue,borderColor:this.chartColors.blue,data:[this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor(),this.randomScalingFactor()]}]}},randomScalingFactor:function(){return Math.round(this.randNum(-100,100))},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.lineData;a.datasets.forEach(function(e,r){var n=e;n.data.forEach(function(a,e){n.data[e]=t.randomScalingFactor()}),a.datasets[r]=n}),this.lineData=a,this.$refs.line.updateChart()},addDataset:function(){for(var t=n()(this.chartColors),a=t[this.lineData.datasets.length%t.length],e=this.chartColors[a],r={label:"第"+(this.lineData.datasets.length+1)+"项",backgroundColor:e,borderColor:e,data:[],fill:!1},i=0;i<this.lineData.labels.length;++i)r.data.push(this.randomScalingFactor());this.lineData.datasets.push(r),this.$refs.line.updateChart()},removeDataset:function(){this.lineData.datasets.splice(0,1),this.$refs.line.updateChart()},addData:function(){var t=this;if(this.lineData.datasets.length>0){var a=this.MONTHS[this.lineData.labels.length%this.MONTHS.length];this.lineData.labels.push(a),this.lineData.datasets.forEach(function(a){a.data.push(t.randomScalingFactor())}),this.$refs.line.updateChart()}},removeData:function(){this.lineData.labels.splice(-1,1),this.lineData.datasets.forEach(function(t){t.data.pop()}),this.$refs.line.updateChart()}},components:{barChart:e("VU/8")(i,s,!1,function(t){e("gda8")},"data-v-43fbf2c0",null).exports}},l={render:function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",[e("bar-chart",{ref:"line",staticStyle:{"max-width":"1000px",margin:"auto"},attrs:{height:200,type:"bar",chartData:t.lineData,options:t.lineOptions}}),t._v(" "),e("el-row",{staticClass:"btn-content",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("删除数据集")]),t._v(" "),e("el-button",{attrs:{type:"info"},on:{click:t.addData}},[t._v("添加数据")]),t._v(" "),e("el-button",{attrs:{type:"warning"},on:{click:t.removeData}},[t._v("删除数据")])],1)],1)},staticRenderFns:[]};var h=e("VU/8")(o,l,!1,function(t){e("G08K")},"data-v-8e92ca9e",null);a.default=h.exports},gda8:function(t,a){}});
//# sourceMappingURL=11.aa443fb0b48c58581056.js.map