getPieView.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="pieView">
  3. <div style="height: 14%;line-height: 30px;text-align: left;padding-left: 10px;color: white;">{{info.config.title||""}}</div>
  4. <div style="width:100%;height:86%;display: inline-block; overflow: hidden;">
  5. <div :id="info.config.idSelector" style="width:100%;height:95%;overflow: hidden;"> </div>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. import * as echarts from "echarts";
  11. export default {
  12. data(){
  13. return{
  14. }
  15. },
  16. props:{
  17. info:{
  18. type:Object,
  19. default:{}
  20. }
  21. },
  22. mounted() {
  23. let this_ = this;
  24. this.$nextTick(()=>{
  25. this_.getMiddleLeft();
  26. })
  27. },
  28. methods:{
  29. getMiddleLeft(){
  30. let chartDom = document.getElementById(this.info.config.idSelector);
  31. // const setEchartWH = {
  32. // //设置控制图表大小变量
  33. // width: 350,
  34. // height: 320,
  35. // };
  36. var myChart = echarts.init(chartDom);
  37. var option;
  38. option = {
  39. title: {
  40. show: true,
  41. left: 'center',
  42. textStyle: {
  43. color: '#fff',
  44. fontSize: 20,
  45. fontWeight: '600'
  46. },
  47. },
  48. color:this.info.color,
  49. tooltip: {
  50. trigger: 'item',
  51. formatter: '{d}%'
  52. },
  53. label: {
  54. formatter: '{b}\n({d}%)'
  55. },
  56. legend: {
  57. show: true,
  58. z: 3,
  59. // orient: 'vertical', 标题横竖//
  60. left: 'right',
  61. textStyle:{
  62. color: '#fff'
  63. }
  64. },
  65. series: [{
  66. type: 'pie',
  67. radius: '50%',
  68. center: ['50%', '50%'],
  69. data:this.info.data,
  70. emphasis: {
  71. itemStyle: {
  72. shadowBlur: 10,
  73. shadowOffsetX: 0,
  74. shadowColor: 'rgba(0, 0, 0, 0.5)'
  75. }
  76. },
  77. }]
  78. };
  79. myChart.setOption(option);
  80. },
  81. }
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .pieView{
  86. // display: flex;
  87. width: 100%;
  88. height: 100%;
  89. overflow: hidden;
  90. background-color: rgba(6,30,93,.5);
  91. }
  92. </style>