(function() { // Vue.component('death-cause', { template: '
\

死亡原因

\
\
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\ \ \ \
\
\
\
\
', props: ["data"], data: function() { return { causeData: [] } }, mounted: function() { var vm = this; setTimeout(function(){ vm.initData(); },50) }, watch:{ data:function(data){ this.data = data; this.initData(); } }, methods: { formatCauseData:function(){ this.causeData = _.map(this.causeData,function(item,idx){ switch(idx){ case 0: item.color = "bgc-00e6f3"; break; case 1: item.color = "bgc-03fa6c"; break; case 2: item.color = "bgc-ff616f"; break; case 3: item.color = "bgc-0fa5f2"; break; case 4: item.color = "bgc-6576e0"; break; case 5: item.color = "bgc-da0ff2"; break; case 6: item.color = "bgc-f24a0f"; break; case 7: item.color = "bgc-ebff61"; break; case 8: item.color = "bgc-fea92f"; break; default:break; } return item; }) }, initData:function(){//死亡原因 this.causeData = this.data["死亡原因"].series[0].data; this.formatCauseData(); var myChart = echarts.init(document.getElementById('div-shiwang-echart')); var option = { // "title": { // "text": "性别分布", // "subtext": "性别分布", // "x": "center" // }, "tooltip": { "trigger": "item" }, color: ["#00e6f3","#03fa6c","#ff616f","#0fa5f2","#6576e0","#da0ff2","#f24a0f","#ebff61","#fea92f"], "series": [{ "center": [ "50%", "50%" ], radius: ['50%', '70%'], "name": "", "type": "pie", "itemStyle": { "normal": { "label": { "show": false }, "labelLine": { "show": false } } }, "data": this.causeData }] } if(myChart){ myChart.clear(); } myChart.setOption(option); } } }) })()