dingdanzhuangtai.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view>
  3. <div class="chart1" ref="chart1"></div>
  4. </view>
  5. </template>
  6. <script>
  7. import echarts from "echarts";
  8. export default {
  9. props: {
  10. // beforeFan:{
  11. // type: Array,
  12. // // 定义是否必须传
  13. // required: false,
  14. // // 定义默认值
  15. // default: []
  16. // },
  17. },
  18. mounted() {
  19. this.getEchartData1()
  20. },
  21. data() {
  22. return {
  23. }
  24. },
  25. methods: {
  26. // 折线图
  27. getEchartData1() {
  28. const chart1 = this.$refs.chart1;
  29. var option = null;
  30. const myChart = this.$echarts.init(chart1);
  31. option = {
  32. tooltip: {
  33. trigger: 'item'
  34. },
  35. color:['rgb(0, 157, 255)','rgb(34, 228, 255)','rgb(59, 255, 208)','rgb(4, 227, 138)',
  36. 'rgb(157, 255, 134)','rgb(254, 229, 136)','rgb(254, 168, 68)','rgb(254, 112, 68)'],
  37. legend: {
  38. top: 'bottom',
  39. bottom:-10
  40. },
  41. series: [
  42. {
  43. name: 'Access From',
  44. type: 'pie',
  45. radius: '50%',
  46. center: ['50%', '40%'],
  47. data: [
  48. { value: 48, name: '待付款' },
  49. { value: 135, name: '已支付' },
  50. { value: 580, name: '已取消' },
  51. { value: 484, name: '已退单' },
  52. { value: 300, name: '待入住' },
  53. { value: 580, name: '已入住' },
  54. { value: 484, name: '已退款' },
  55. { value: 300, name: '已消费' }
  56. ],
  57. emphasis: {
  58. itemStyle: {
  59. shadowBlur: 10,
  60. shadowOffsetX: 0,
  61. shadowColor: 'rgba(0, 0, 0, 0.5)'
  62. }
  63. }
  64. }
  65. ]
  66. };
  67. myChart.setOption(option);
  68. window.addEventListener("resize", function () {
  69. myChart.resize();
  70. });
  71. this.$on("hook:destroyed", () => {
  72. window.removeEventListener("resize", function () {
  73. chart1.resize();
  74. });
  75. });
  76. return option;
  77. },
  78. },
  79. }
  80. </script>
  81. <style>
  82. .chart1 {
  83. width: 100%;
  84. height: 100%;
  85. display: block;
  86. }
  87. </style>