productProportion.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div>
  3. <div id="productProportion" style="width:420px; height: 160px;"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import resize from "./mixins/resize";
  8. import { selectLast } from "@/api/aspen/dashboarddata";
  9. export default {
  10. data() {
  11. return {
  12. chart: null,
  13. // dashboard抓取数据
  14. dashboarddata: {
  15. energyYixi: null,
  16. energyBingxi: null,
  17. energyQingqi: null,
  18. energyJiawan: null,
  19. energyCsi: null,
  20. energyBenzene: null,
  21. energyToluene: null,
  22. energyXylene: null,
  23. energyTanliu: null,
  24. energyWashoil: null,
  25. energyTanwu: null,
  26. energyIma: null,
  27. energyCjiu: null,
  28. energyRpg: null,
  29. energyfeedNap: null,
  30. energyfeedYiwan: null,
  31. energyfeedTanwu: null,
  32. energyfeedTanliu: null,
  33. energyfeedLpg: null,
  34. energyOffgas: null,
  35. energyLpg: null,
  36. steamSsinfur: null,
  37. steamSsoutlet: null,
  38. steamSsoutaeu: null,
  39. steamSsoutesi: null,
  40. steamSsoutksan: null,
  41. steamSsoutsc: null,
  42. steamHsinsub: null,
  43. steamHsinlet: null,
  44. steamHsinksan: null,
  45. steamHsoutpjiu: null,
  46. steamHsoutaeu: null,
  47. steamHsoutlet: null,
  48. steamHsoutesan: null,
  49. steamHsoutphyi: null,
  50. steamHsoutpher: null,
  51. steamHsouthwu: null,
  52. steamHsoutkliu: null,
  53. steamHsoutsc: null,
  54. steamHhpsub: null,
  55. steamMsinaeu: null,
  56. steamMsinlet: null,
  57. steamMsinphyi: null,
  58. steamMsinkliu: null,
  59. steamMsoutflare: null,
  60. steamMsoutaeu: null,
  61. steamMsoutsctu: null,
  62. steamMsouteer: null,
  63. steamMsoutfur: null,
  64. steamMsoutva: null,
  65. steamMsouttracing: null,
  66. steamLsinsub: null,
  67. steamLsinpjiu: null,
  68. steamLsinaeu: null,
  69. steamLsineer: null,
  70. steamLsinpher: null,
  71. steamLsoutsctu: null,
  72. steamLsoutvjiu: null,
  73. steamLsoutewuliu: null,
  74. steamLsoutewusan: null,
  75. steamLsouttracing: null,
  76. steamLsoutesan: null,
  77. steamLsoutesi: null,
  78. steamLsoutother: null
  79. },
  80. // 查询参数
  81. queryParams: {
  82. },
  83. };
  84. },
  85. mixins: [resize],
  86. mounted() {
  87. this.getList()
  88. // 每隔30秒请求一次数据
  89. window.setInterval(() => {undefined
  90. setTimeout(() => {undefined
  91. ///调取接口获取数据
  92. this.getList();
  93. }, 0)
  94. }, 10000)
  95. },
  96. methods: {
  97. /** 查询dashboard抓取数据列表 */
  98. getList()
  99. {
  100. selectLast(this.queryParams).then(response => {
  101. this.dashboarddata = response.data;
  102. this.initChart();
  103. });
  104. },
  105. initChart() {
  106. // 基于准备好的dom,初始化echarts实例
  107. this.chart = this.echarts.init(document.getElementById("productProportion"));
  108. this.chart.setOption({
  109. color: [
  110. "#37a2da",
  111. "#32c5e9",
  112. "#9fe6b8",
  113. "#ffdb5c",
  114. "#ff9f7f",
  115. "#fb7293",
  116. "#e7bcf3",
  117. "#8378ea"
  118. ],
  119. tooltip: {
  120. trigger: "item",
  121. formatter: "{b} : {c} ({d}%)"
  122. },
  123. toolbox: {
  124. show: true
  125. },
  126. calculable: true,
  127. legend: [{
  128. icon: "circle",
  129. orient: 'vertical',
  130. right: 62,
  131. top: 40,
  132. bottom: 20,
  133. data: ["H2", "C2H4", "CH4", "C3H6"],
  134. textStyle: {
  135. color: "#fff"
  136. }
  137. }, {
  138. icon: "circle",
  139. orient: 'vertical',
  140. right: -6,
  141. top: 40,
  142. bottom: 20,
  143. data: ["Offgas", "LPG", "C4", "RPG"],
  144. textStyle: {
  145. color: "#fff"
  146. }
  147. }],
  148. label: {
  149. alignTo: 'edge',
  150. formatter: '{name|{b}}\n{weight|{c} 吨({d}%)}',
  151. minMargin: 5,
  152. edgeDistance: 10,
  153. lineHeight: 15,
  154. rich: {
  155. name: {
  156. fontSize: 12,
  157. color: '#ffffff'
  158. },
  159. weight: {
  160. fontSize: 8,
  161. color: '#ffffff'
  162. }
  163. }
  164. },
  165. series: [
  166. {
  167. type: "pie",
  168. radius: [10, 55],
  169. roseType: "area",
  170. center: ["36%", "50%"],
  171. data: [
  172. { value: this.dashboarddata.energyQingqi, name: "H2" },
  173. { value: this.dashboarddata.energyYixi, name: "C2H4" },
  174. { value: this.dashboarddata.energyJiawan, name: "CH4" },
  175. { value: this.dashboarddata.energyBingxi, name: "C3H6" },
  176. { value: this.dashboarddata.energyOffgas, name: "Offgas" },
  177. { value: this.dashboarddata.energyLpg, name: "LPG" },
  178. { value: this.dashboarddata.energyCsi, name: "C4" },
  179. { value: this.dashboarddata.energyRpg, name: "RPG" }
  180. ],
  181. }
  182. ]
  183. });
  184. }
  185. },
  186. destroyed() {
  187. window.onresize = null;
  188. }
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. </style>