EBottom3.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="container">
  3. <div id="EBottom3" style="height: 100%"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: "EBottom3",
  9. data() {
  10. return {
  11. X: [1500, 1858, 1955, 2485, 3857],
  12. Y: ["其他", "江苏", "上海", "福建", "浙江"],
  13. };
  14. },
  15. mounted() {
  16. this.drawChart();
  17. },
  18. methods: {
  19. drawChart() {
  20. // 基于准备好的dom,初始化echarts实例
  21. let myChart = this.$echarts.init(
  22. document.getElementById("EBottom3")
  23. );
  24. // 指定图表的配置项和数据
  25. let option = {
  26. title: {
  27. text: "销售地排行",
  28. left: "4%",
  29. top: "4%",
  30. textStyle: {
  31. fontSize: 25,
  32. color: "#fff",
  33. },
  34. },
  35. grid: {
  36. x: "5%",
  37. y: "15%",
  38. x2: "8%",
  39. y2: "5%",
  40. containLabel: true,
  41. },
  42. tooltip: {
  43. trigger: "axis",
  44. // formatter(val) {
  45. // console.log(val)
  46. // },
  47. textStyle: {
  48. fontSize: 25,
  49. color: "#fff",
  50. },
  51. },
  52. yAxis: {
  53. data: this.Y,
  54. axisLine: {
  55. show: true,
  56. lineStyle: {
  57. type: "solid",
  58. color: "#fff", //左边线的颜色
  59. width: "2", //坐标线的宽度
  60. },
  61. },
  62. axisLabel: {
  63. textStyle: {
  64. color: "#fff",
  65. fontSize: 20,
  66. },
  67. },
  68. // name: "(时间)",
  69. nameTextStyle: {
  70. fontSize: 20,
  71. color: "#fff",
  72. },
  73. },
  74. xAxis: {
  75. splitLine: { show: false },
  76. axisLine: {
  77. show: true,
  78. lineStyle: {
  79. type: "solid",
  80. color: "#fff", //左边线的颜色
  81. width: "2", //坐标线的宽度
  82. },
  83. },
  84. axisLabel: {
  85. textStyle: {
  86. color: "#fff",
  87. fontSize: 20,
  88. },
  89. },
  90. // name: "(万元)",
  91. nameTextStyle: {
  92. fontSize: 20,
  93. },
  94. axisLabel: {
  95. textStyle: {
  96. color: "#fff",
  97. fontSize: 20,
  98. },
  99. },
  100. },
  101. series: [
  102. {
  103. //真实数据所在
  104. name: "胴体",
  105. type: "bar",
  106. barWidth: "60%",
  107. itemStyle: {
  108. color: new this.$echarts.graphic.LinearGradient(
  109. 0,
  110. 0,
  111. 1,
  112. 0,
  113. [
  114. {
  115. offset: 0,
  116. color: "#10303F",
  117. },
  118. {
  119. offset: 0.4,
  120. color: "#16AFB8",
  121. },
  122. {
  123. offset: 1,
  124. color: "#16AFB8",
  125. },
  126. ]
  127. ),
  128. barBorderRadius: [0, 100, 100, 0],
  129. },
  130. label: {
  131. show: true, //开启显示
  132. position: "right", //在上方显示
  133. textStyle: {
  134. //数值样式
  135. fontSize: 20,
  136. color: '#7CF5E9'
  137. },
  138. formatter: "{c}",
  139. },
  140. data: this.X,
  141. },
  142. {
  143. type: "bar",
  144. itemStyle: {
  145. color: "#052E3D",
  146. barBorderRadius: 3,
  147. barBorderRadius: [0, 100, 100, 0],
  148. },
  149. barGap: "-100%",
  150. barWidth: "60%",
  151. z: -1,
  152. data: [...this.X].fill(
  153. Math.ceil(Math.max(...this.X) / 1000) * 1000
  154. ),
  155. },
  156. ],
  157. };
  158. // 使用刚指定的配置项和数据显示图表。
  159. myChart.setOption(option);
  160. },
  161. },
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. </style>