death-cause.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. (function() {
  2. //<img src="../images/icon.png" class="icon-img">
  3. Vue.component('death-cause', {
  4. template: '<div style="height: 100%;">\
  5. <h4 class="c-b5e1fc c-f16 c-t-center div-common-title">死亡原因</h4>\
  6. <div class="" style="height: 85%;">\
  7. <div id="div-shiwang-echart" class="ml10"></div>\
  8. <div class="div-siwang-type" v-if="causeData.length>0">\
  9. <div class="div-webkit-box" v-for="(cause, idx) in causeData">\
  10. <div class="c-b5e1fc div-webkit-box-flex1 c-f14">\
  11. <label class="bar-a" v-bind:class="idx | formatData"></label>\
  12. <label class="ml10">{{cause.name}}</label>\
  13. <label class="ml20">{{cause.value}}</label>\
  14. </div>\
  15. </div>\
  16. </div>\
  17. </div>\
  18. </div>',
  19. props: ["data"],
  20. data: function() {
  21. return {
  22. causeData: []
  23. }
  24. },
  25. mounted: function() {
  26. },
  27. watch:{
  28. data:function(data){
  29. this.data = data;
  30. this.initData();
  31. }
  32. },
  33. filters:{
  34. formatData:function(index){
  35. var colorArr = ["bgc-00e6f3","bgc-03fa6c","bgc-ff616f","bgc-0fa5f2","bgc-6576e0","bgc-da0ff2","bgc-f24a0f","bgc-ebff61","bgc-fea92f"];
  36. return colorArr[index];
  37. }
  38. },
  39. methods: {
  40. initData:function(){//死亡原因
  41. this.causeData = this.data["死亡原因"].series[0].data;
  42. var myChart = echarts.init(document.getElementById('div-shiwang-echart'));
  43. var option = {
  44. // "title": {
  45. // "text": "性别分布",
  46. // "subtext": "性别分布",
  47. // "x": "center"
  48. // },
  49. "tooltip": {
  50. "trigger": "item"
  51. },
  52. color: ["#00e6f3","#03fa6c","#ff616f","#0fa5f2","#6576e0","#da0ff2","#f24a0f","#ebff61","#fea92f"],
  53. "series": [{
  54. "center": [
  55. "50%",
  56. "50%"
  57. ],
  58. radius: ['50%', '70%'],
  59. "name": "",
  60. "type": "pie",
  61. "itemStyle": {
  62. "normal": {
  63. "label": {
  64. "show": false
  65. },
  66. "labelLine": {
  67. "show": false
  68. }
  69. }
  70. },
  71. "data": this.causeData
  72. }]
  73. }
  74. if(myChart){
  75. myChart.clear();
  76. }
  77. myChart.setOption(option);
  78. }
  79. }
  80. })
  81. })()