nestingPie.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div :id="id" style="height: 100%;width:100%;padding: 20px;"></div>
  3. </template>
  4. <script>
  5. export default {
  6. data () {
  7. return {}
  8. },
  9. props:{
  10. id:{
  11. type: String
  12. }
  13. },
  14. mounted(){
  15. this.drawLine();
  16. },
  17. methods:{
  18. drawLine(){
  19. let _this = this
  20. // 基于准备好的dom,初始化echarts实例
  21. let myChart = this.$echarts.init(document.getElementById(this.id));
  22. myChart.setOption({
  23. tooltip: {
  24. trigger: 'item',
  25. formatter: "{a} <br/>{b}: {c} ({d}%)"
  26. },
  27. // legend: {
  28. // orient: 'vertical',
  29. // x: 'left',
  30. // data:['直达','营销广告','搜索引擎','邮件营销','联盟广告','视频广告','百度','谷歌','必应','其他']
  31. // },
  32. series: [
  33. {
  34. name:'访问来源',
  35. type:'pie',
  36. selectedMode: 'single',
  37. radius: [0, '30%'],
  38. label: {
  39. normal: {
  40. position: 'inner'
  41. }
  42. },
  43. labelLine: {
  44. normal: {
  45. show: false
  46. }
  47. },
  48. data:[
  49. {value:335, name:'直达', selected:true},
  50. {value:679, name:'营销广告'},
  51. {value:1548, name:'搜索引擎'}
  52. ]
  53. },
  54. {
  55. name:'访问来源',
  56. type:'pie',
  57. radius: ['40%', '55%'],
  58. label: {
  59. normal: {
  60. formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ',
  61. backgroundColor: '#eee',
  62. borderColor: '#aaa',
  63. borderWidth: 1,
  64. borderRadius: 4,
  65. // shadowBlur:3,
  66. // shadowOffsetX: 2,
  67. // shadowOffsetY: 2,
  68. // shadowColor: '#999',
  69. // padding: [0, 7],
  70. rich: {
  71. a: {
  72. color: '#999',
  73. lineHeight: 22,
  74. align: 'center'
  75. },
  76. // abg: {
  77. // backgroundColor: '#333',
  78. // width: '100%',
  79. // align: 'right',
  80. // height: 22,
  81. // borderRadius: [4, 4, 0, 0]
  82. // },
  83. hr: {
  84. borderColor: '#aaa',
  85. width: '100%',
  86. borderWidth: 0.5,
  87. height: 0
  88. },
  89. b: {
  90. fontSize: 16,
  91. lineHeight: 33
  92. },
  93. per: {
  94. color: '#eee',
  95. backgroundColor: '#334455',
  96. padding: [2, 4],
  97. borderRadius: 2
  98. }
  99. }
  100. }
  101. },
  102. data:[
  103. {value:335, name:'直达'},
  104. {value:310, name:'邮件营销'},
  105. {value:234, name:'联盟广告'},
  106. {value:135, name:'视频广告'},
  107. {value:1048, name:'百度'},
  108. {value:251, name:'谷歌'},
  109. {value:147, name:'必应'},
  110. {value:102, name:'其他'}
  111. ]
  112. }
  113. ]
  114. });
  115. }
  116. }
  117. }
  118. </script>
  119. <style>
  120. </style>