BprogramAmount.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="chinaMap">
  3. <div class="map" ref="MapMountNode"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. props: ["listData"],
  9. data() {
  10. return {};
  11. },
  12. methods: {
  13. //先定义个方法
  14. myEcharts() {
  15. //把echarts绑定到显示元素上
  16. const myChart = this.$echarts.init(this.$refs.MapMountNode);
  17. //设置图表属性
  18. // 经营数据
  19. const option = {
  20. color: ["#fc8452"],
  21. tooltip: {
  22. trigger: "axis",
  23. axisPointer: {
  24. type: "shadow",
  25. },
  26. },
  27. grid: {
  28. left: "7%",
  29. right: "4%",
  30. bottom: "3%",
  31. top: "1%",
  32. containLabel: true,
  33. },
  34. xAxis: [
  35. {
  36. type: "value",
  37. },
  38. ],
  39. yAxis: [
  40. {
  41. type: "category",
  42. axisTick: {
  43. show: false,
  44. },
  45. data: [
  46. "单次三个项目",
  47. "单次两个项目",
  48. "三次到店用户数",
  49. "两次到店用户数",
  50. "美妆购买总用户数",
  51. "总用户数",
  52. ],
  53. },
  54. ],
  55. series: [
  56. {
  57. name: "数量",
  58. type: "bar",
  59. label: {
  60. show: true,
  61. position: "inside",
  62. },
  63. emphasis: {
  64. focus: "series",
  65. },
  66. itemStyle: {
  67. normal: {
  68. label: {
  69. show: true, //开启显示数值
  70. position: "right", //数值在上方显示
  71. textStyle: {
  72. //数值样式
  73. color: "#9b9ca2", //字体颜色
  74. fontSize: 14, //字体大小
  75. },
  76. },
  77. },
  78. },
  79. data: [
  80. this.listData.three_project,
  81. this.listData.two_project,
  82. this.listData.user_three,
  83. this.listData.user_two,
  84. this.listData.beauty_products,
  85. this.listData.total_user,
  86. ],
  87. },
  88. ],
  89. };
  90. //数据绑定到表格
  91. myChart.setOption(option);
  92. window.addEventListener("resize", function () {
  93. myChart.resize(); //myChart指自己定义的echartsDom对象
  94. });
  95. },
  96. },
  97. // 监听父组件传过来的值的变化
  98. watch: {
  99. listData: {
  100. handler(val) {
  101. this.myEcharts();
  102. },
  103. },
  104. },
  105. mounted() {
  106. this.myEcharts();
  107. },
  108. };
  109. </script>
  110. <style scoped>
  111. .map {
  112. width: 160%;
  113. height: 300px;
  114. }
  115. </style>