index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div
  3. ref="echartD"
  4. style="width: 100%; height: 100%; display: flex; justify-content: center"
  5. ></div>
  6. </template>
  7. <script>
  8. import * as echarts from "echarts";
  9. export default {
  10. props: {
  11. dataMap: { type: Array, default: () => [] },
  12. color: { type: String, default: () => "#468EFD" },
  13. },
  14. data() {
  15. return {};
  16. },
  17. watch: {
  18. dataMap(val) {
  19. this.getData(val);
  20. },
  21. },
  22. mounted() {
  23. this.getData();
  24. },
  25. methods: {
  26. getData() {
  27. if(document.body.clientWidth >1940){
  28. echarts.init(this.$refs.echartD).setOption({
  29. backgroundColor: "transparent",
  30. color: [
  31. "rgba(255,199,6,1)",
  32. "rgba(11,255,109,1)",
  33. "rgba(10,218,255,1)",
  34. "rgba(12,210,0,1)",
  35. ],
  36. series: [
  37. {
  38. zlevel: 1,
  39. name: "漏斗图",
  40. type: "funnel",
  41. left: 30,
  42. top: 0,
  43. bottom: 0,
  44. width: "100%",
  45. min: 0,
  46. max: 120,
  47. minSize: "3%",
  48. maxSize: "100%",
  49. sort: "ascending",
  50. gap: 15,
  51. label: {
  52. show: true,
  53. position: "left",
  54. // width: "400px",
  55. align: "left",
  56. textBorderColor: "transparent",
  57. formatter: function (params) {
  58. return params.data.reaVal + "%";
  59. },
  60. // fontSize: 24,
  61. fontSize: 100,
  62. opacity: 1,
  63. fontFamily: '"DS", "DS-B", "DS-BB", "DS-BS"',
  64. },
  65. labelLine: {
  66. show: true,
  67. length: 50,
  68. lineStyle: {
  69. width: 1,
  70. type: "solid",
  71. },
  72. },
  73. itemStyle: {
  74. borderColor: "transparent",
  75. borderWidth: 0,
  76. opacity: 0.5,
  77. shadowColor: "#CCC",
  78. // shadowOffsetX: 1,
  79. // shadowBlur: 1,
  80. // shadowOffsetY: -1,
  81. },
  82. emphasis: {
  83. label: {
  84. fontSize: 30,
  85. },
  86. },
  87. data:this.dataMap,
  88. },
  89. ],
  90. });
  91. }else{
  92. echarts.init(this.$refs.echartD).setOption({
  93. backgroundColor: "transparent",
  94. color: [
  95. "rgba(255,199,6,1)",
  96. "rgba(11,255,109,1)",
  97. "rgba(10,218,255,1)",
  98. "rgba(12,210,0,1)",
  99. ],
  100. series: [
  101. {
  102. zlevel: 1,
  103. name: "漏斗图",
  104. type: "funnel",
  105. left: 30,
  106. top: 0,
  107. bottom: 0,
  108. width: "100%",
  109. min: 0,
  110. max: 120,
  111. minSize: "3%",
  112. maxSize: "100%",
  113. sort: "ascending",
  114. gap: 15,
  115. label: {
  116. show: true,
  117. position: "left",
  118. // width: "400px",
  119. align: "left",
  120. textBorderColor: "transparent",
  121. formatter: function (params) {
  122. return params.data.reaVal + "%";
  123. },
  124. // fontSize: 24,
  125. fontSize: 25,
  126. opacity: 1,
  127. fontFamily: '"DS", "DS-B", "DS-BB", "DS-BS"',
  128. },
  129. labelLine: {
  130. show: true,
  131. length: 50,
  132. lineStyle: {
  133. width: 1,
  134. type: "solid",
  135. },
  136. },
  137. itemStyle: {
  138. borderColor: "transparent",
  139. borderWidth: 0,
  140. opacity: 0.5,
  141. shadowColor: "#CCC",
  142. // shadowOffsetX: 1,
  143. // shadowBlur: 1,
  144. // shadowOffsetY: -1,
  145. },
  146. emphasis: {
  147. label: {
  148. fontSize: 30,
  149. },
  150. },
  151. data:this.dataMap,
  152. },
  153. ],
  154. });
  155. }
  156. },
  157. resize() {
  158. echarts.init(this.$refs.echartD).resize();
  159. },
  160. },
  161. };
  162. </script>
  163. <style scoped>
  164. </style>