suppEchart.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div
  3. ref="testLine"
  4. style="width: 1650px; height: 240px; margin: -60px 0 0 0"
  5. ></div>
  6. </template>
  7. <script>
  8. /**
  9. * 顶板压力图
  10. * @module suppEchart
  11. */
  12. import { mapState } from "vuex";
  13. export default {
  14. data() {
  15. return {
  16. zhijiaId: [],
  17. barData: [],
  18. currentChartId: 1,
  19. xData: new Array(30).fill("-"),
  20. yData: new Array(30).fill("-"),
  21. count: 0,
  22. myChart: null,
  23. option: {
  24. // backgroundColor: "#0f375f",
  25. tooltip: {
  26. trigger: "axis",
  27. axisPointer: {
  28. type: "shadow",
  29. label: {
  30. show: true,
  31. backgroundColor: "#333",
  32. },
  33. },
  34. },
  35. title: {
  36. text: "顶板压力",
  37. padding: [5, 70],
  38. textStyle: {
  39. fontWeight: "normal", //标题颜色
  40. color: "#4ADEFE",
  41. fontSize: 18,
  42. },
  43. },
  44. xAxis: {
  45. data: [],
  46. axisLine: {
  47. lineStyle: {
  48. color: "#ccc",
  49. },
  50. },
  51. },
  52. yAxis: {
  53. splitLine: { show: false },
  54. axisLine: {
  55. lineStyle: {
  56. color: "#ccc",
  57. },
  58. },
  59. },
  60. series: [
  61. {
  62. type: "bar",
  63. barWidth: 3,
  64. itemStyle: {
  65. normal: {
  66. barBorderRadius: 5,
  67. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  68. { offset: 0, color: "#14c8d4" },
  69. { offset: 1, color: "#43eec6" },
  70. ]),
  71. },
  72. },
  73. data: [],
  74. },
  75. ],
  76. },
  77. };
  78. },
  79. computed: {
  80. ...mapState(["websocketIP"]),
  81. },
  82. methods: {
  83. /**
  84. * 获取各个支架顶板压力值
  85. * @function getData
  86. */
  87. getData() {
  88. var count = 0;
  89. this.barData.shift(this.barData[0]);
  90. this.barData.push(parseInt(Math.random() * (40 - 25 + 1) + 25, 10));
  91. console.log(this.barData);
  92. this.myChart.setOption({
  93. xAxis: [
  94. {
  95. data: this.zhijiaId,
  96. },
  97. ],
  98. series: [
  99. {
  100. data: this.barData,
  101. },
  102. ],
  103. });
  104. },
  105. },
  106. created() {
  107. // this.getData();
  108. var index = 190;
  109. for (var i = 0; i < 190; i++) {
  110. this.zhijiaId.push(index--);
  111. var data = parseInt(Math.random() * (40 - 25 + 1) + 25, 10);
  112. this.barData.push(data);
  113. }
  114. console.log(this.zhijiaId);
  115. },
  116. mounted() {
  117. // 先画图
  118. this.myChart = this.$echarts.init(this.$refs.testLine);
  119. // 获取数据
  120. this.myChart.setOption(this.option);
  121. this.timer = setInterval(() => {
  122. this.getData();
  123. }, 3000);
  124. // this.websocket = new WebSocket(
  125. // `ws://${this.websocketIP}/hbase/ws/belt/${this.id}`
  126. // );
  127. // this.initWebSocket();
  128. },
  129. destroyed() {
  130. clearInterval(this.timer);
  131. },
  132. };
  133. </script>
  134. <style scoped>
  135. .select-veido .el-select {
  136. width: 100px;
  137. margin-left: 10px;
  138. }
  139. .select-veido >>> .el-input--small .el-input__inner {
  140. background: none;
  141. }
  142. .select-veido >>> .el-input__inner {
  143. border: 0;
  144. }
  145. </style>