productProportion.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div id="app-container-proportion">
  3. <div class="bg-color-black">
  4. <div class="d-flex pt-2 pl-2">
  5. <span style="color:#5cd9e8">
  6. <icon name="chart-area"></icon>
  7. </span>
  8. <div class="d-flex">
  9. <span class="fs-xl text mx-2">产品占比图</span>
  10. <div class="decoration2">
  11. <dv-decoration-2 :reverse="true" style="width:5px;height:200px;" />
  12. </div>
  13. </div>
  14. </div>
  15. <div>
  16. <div>
  17. <div id="productProportion" style="width:420px; height: 160px;"></div>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import productProportion from "../dashboard/productProportion";
  25. import resize from "@/views/dashboard/mixins/resize";
  26. export default {
  27. props: ['dashboarddata'],
  28. components: {
  29. productProportion
  30. },
  31. data() {
  32. return {
  33. chart: null,
  34. // 查询参数
  35. queryParams: {
  36. },
  37. };
  38. },
  39. mixins: [resize],
  40. mounted() {
  41. this.initChart()
  42. // 每隔30秒请求一次数据
  43. window.setInterval(() => {
  44. setTimeout(() => {
  45. ///调取接口获取数据
  46. this.initChart();
  47. }, 0)
  48. }, 20000)
  49. },
  50. methods: {
  51. initChart() {
  52. // 基于准备好的dom,初始化echarts实例
  53. this.chart = this.echarts.init(document.getElementById("productProportion"));
  54. this.chart.setOption({
  55. color: [
  56. "#37a2da",
  57. "#32c5e9",
  58. "#9fe6b8",
  59. "#ffdb5c",
  60. "#ff9f7f",
  61. "#fb7293",
  62. "#e7bcf3",
  63. "#8378ea"
  64. ],
  65. tooltip: {
  66. trigger: "item",
  67. formatter: "{b} : {c} ({d}%)"
  68. },
  69. toolbox: {
  70. show: true
  71. },
  72. calculable: true,
  73. legend: [{
  74. icon: "circle",
  75. orient: 'vertical',
  76. right: 62,
  77. top: 40,
  78. bottom: 20,
  79. data: ["H2", "C2H4", "CH4", "C3H6"],
  80. textStyle: {
  81. color: "#fff"
  82. }
  83. }, {
  84. icon: "circle",
  85. orient: 'vertical',
  86. right: -6,
  87. top: 40,
  88. bottom: 20,
  89. data: ["Offgas", "LPG", "C4", "RPG"],
  90. textStyle: {
  91. color: "#fff"
  92. }
  93. }],
  94. label: {
  95. alignTo: 'edge',
  96. formatter: '{name|{b}}\n{weight|{c} 吨({d}%)}',
  97. minMargin: 5,
  98. edgeDistance: 10,
  99. lineHeight: 15,
  100. rich: {
  101. name: {
  102. fontSize: 12,
  103. color: '#ffffff'
  104. },
  105. weight: {
  106. fontSize: 8,
  107. color: '#ffffff'
  108. }
  109. }
  110. },
  111. series: [
  112. {
  113. type: "pie",
  114. radius: [10, 55],
  115. roseType: "area",
  116. center: ["36%", "50%"],
  117. data: [
  118. { value: this.dashboarddata.energyQingqi, name: "H2" },
  119. { value: this.dashboarddata.energyYixi, name: "C2H4" },
  120. { value: this.dashboarddata.energyJiawan, name: "CH4" },
  121. { value: this.dashboarddata.energyBingxi, name: "C3H6" },
  122. { value: this.dashboarddata.energyOffgas, name: "Offgas" },
  123. { value: this.dashboarddata.energyLpg, name: "LPG" },
  124. { value: this.dashboarddata.energyCsi, name: "C4" },
  125. { value: this.dashboarddata.energyRpg, name: "RPG" }
  126. ],
  127. }
  128. ]
  129. });
  130. }
  131. },
  132. destroyed() {
  133. window.onresize = null;
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. #app-container-proportion {
  139. padding: 0.2rem 0.2rem 0;
  140. height: 240px;
  141. min-width: 3.75rem;
  142. border-radius: 0.0625rem;
  143. .bg-color-black {
  144. height: 90%;
  145. border-radius: 0.125rem;
  146. }
  147. .text {
  148. color: #c3cbde;
  149. } //下滑线动态
  150. .decoration2 {
  151. position: absolute;
  152. right: 0.125rem;
  153. }
  154. .chart-box {
  155. margin-top: 0.2rem;
  156. width: 2.125rem;
  157. height: 2.125rem;
  158. .active-ring-name {
  159. padding-top: 0.125rem;
  160. }
  161. }
  162. }
  163. </style>