productData.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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: ["#91cc75"],
  21. title: {
  22. text: "产品数据",
  23. // textStyle: {
  24. // color: "#6d767e",
  25. // },
  26. },
  27. tooltip: {
  28. trigger: "axis",
  29. axisPointer: {
  30. type: "shadow",
  31. },
  32. },
  33. grid: {
  34. left: "3%",
  35. right: "4%",
  36. bottom: "3%",
  37. containLabel: true,
  38. },
  39. xAxis: [
  40. {
  41. type: "value",
  42. },
  43. ],
  44. yAxis: [
  45. {
  46. type: "category",
  47. axisTick: {
  48. show: false,
  49. },
  50. data: ["购买订单数", "购买人数", "购买金额"],
  51. },
  52. ],
  53. series: [
  54. {
  55. name: "数量",
  56. type: "bar",
  57. label: {
  58. show: true,
  59. position: "inside",
  60. },
  61. itemStyle: {
  62. normal: {
  63. label: {
  64. show: true, //开启显示数值
  65. position: "right", //数值在上方显示
  66. textStyle: {
  67. //数值样式
  68. color: "#9b9ca2", //字体颜色
  69. fontSize: 14, //字体大小
  70. },
  71. },
  72. },
  73. },
  74. emphasis: {
  75. focus: "series",
  76. },
  77. data: [
  78. this.listData.product_data.order,
  79. this.listData.product_data.people,
  80. this.listData.product_data.money,
  81. ],
  82. },
  83. ],
  84. };
  85. //数据绑定到表格
  86. myChart.setOption(option);
  87. window.addEventListener("resize", function () {
  88. myChart.resize(); //myChart指自己定义的echartsDom对象
  89. });
  90. },
  91. },
  92. // 监听父组件传过来的值的变化
  93. watch: {
  94. listData: {
  95. handler(val) {
  96. this.myEcharts();
  97. },
  98. },
  99. },
  100. mounted() {
  101. this.myEcharts();
  102. },
  103. };
  104. </script>
  105. <style scoped>
  106. .map {
  107. width: 99%;
  108. /* height: 280px; */
  109. height: 20vh;
  110. /* border: 1px solid saddlebrown; */
  111. }
  112. </style>