index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="main">
  3. <div class="left">
  4. <pieChart :value="80" title="矿区总分" size="150px" />
  5. </div>
  6. <div class="right">
  7. <div ref="bar" style="height: 170px; width: 230px"></div>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import pieChart from "@/common/pieChart";
  13. export default {
  14. components: {
  15. pieChart,
  16. },
  17. data() {
  18. return {
  19. myChart: null,
  20. xData: [],
  21. yData: [],
  22. };
  23. },
  24. mounted() {
  25. const option = {
  26. title: {
  27. text: "区域得分",
  28. // 标题内边距 上下边距 左右边距
  29. padding: [10, 0, 0, 8],
  30. textStyle: {
  31. color: "white",
  32. fontSize: 16,
  33. },
  34. },
  35. tooltip: {
  36. // show: false,
  37. trigger: "axis",
  38. axisPointer: {
  39. type: "shadow",
  40. },
  41. formatter: (params) => {
  42. let round =
  43. '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#4693EC;"></span>';
  44. return round + "得分:" + params[0].data;
  45. },
  46. },
  47. color: ["#FF6666", "#99CC66", "#FFFF66"],
  48. legend: {
  49. show: false,
  50. orient: "horizontal",
  51. left: "right",
  52. padding: [25, 20],
  53. icon: "rect",
  54. textStyle: {
  55. color: "#fff",
  56. },
  57. data: ["压力超限", "压力正常", "压力过低"],
  58. },
  59. grid: {
  60. top: "22%",
  61. left: "3%",
  62. right: "4%",
  63. bottom: "3%",
  64. containLabel: true,
  65. },
  66. xAxis: [
  67. {
  68. type: "category",
  69. axisLabel: {
  70. color: "#fff",
  71. interval: 0,
  72. fontSize: 9,
  73. },
  74. axisLine: {
  75. show: true,
  76. },
  77. axisLine: {
  78. show: false
  79. },
  80. data: ["A区", "B区", "C区", "D区"],
  81. },
  82. ],
  83. yAxis: [
  84. {
  85. type: "value",
  86. axisLabel: {
  87. color: "#fff",
  88. // fontSize: 11,
  89. },
  90. axisLine: {
  91. show: false
  92. },
  93. min: 0,
  94. max: 100,
  95. nameTextStyle: {
  96. color: "white",
  97. padding: [0, 0, 0, -30],
  98. },
  99. splitLine: {
  100. show: false,
  101. lineStyle: {
  102. type: "dotted",
  103. color: "#fff",
  104. },
  105. },
  106. },
  107. ],
  108. series: [
  109. {
  110. name: "数据",
  111. type: "bar",
  112. barWidth: 12,
  113. itemStyle: {
  114. normal: {
  115. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  116. {
  117. offset: 0,
  118. color: "#00FFE3",
  119. },
  120. {
  121. offset: 1,
  122. color: "#4693EC",
  123. },
  124. ]),
  125. },
  126. },
  127. // barWidth: "10",
  128. barCategoryGap: "5%",
  129. data: [70, 75, 88, 92],
  130. },
  131. ],
  132. };
  133. this.myChart = this.$echarts.init(this.$refs.bar);
  134. // 获取数据
  135. this.myChart.setOption(option);
  136. },
  137. };
  138. </script>
  139. <style scoped lang="less">
  140. .main {
  141. display: flex;
  142. }
  143. </style>