|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<!-- 支架压力柱状图 -->
|
|
|
- <div id="bar" style="height: 300px; width: 600px;margin-top:10px"></div>
|
|
|
+ <div id="bar" style="height: 300px; width: 600px; margin-top: 10px"></div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
myChart: null,
|
|
|
option: {
|
|
|
title: {
|
|
|
- text: '支架压力监控',
|
|
|
+ text: "支架压力监控",
|
|
|
padding: [5, 230],
|
|
|
textStyle: {
|
|
|
fontWeight: "normal", //标题颜色
|
|
@@ -34,16 +34,6 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
color: ["#FF6666", "#99CC66", "#FFFF66"],
|
|
|
- // legend: {
|
|
|
- // orient: "vertical",
|
|
|
- // x: "left",
|
|
|
- // y: "top",
|
|
|
- // data: ["压力超限", "压力过低", "压力正常"],
|
|
|
- // textStyle: {
|
|
|
- // fontWeight: "normal",
|
|
|
- // color: "#fff",
|
|
|
- // },
|
|
|
- // },
|
|
|
legend: {
|
|
|
orient: "vertical",
|
|
|
left: "right",
|
|
@@ -51,7 +41,7 @@ export default {
|
|
|
textStyle: {
|
|
|
color: "#fff",
|
|
|
},
|
|
|
- data: ["压力超限", "压力过低", "压力正常"],
|
|
|
+ data: ["压力超限", "压力正常", "压力过低"],
|
|
|
},
|
|
|
grid: {
|
|
|
left: "3%",
|
|
@@ -73,7 +63,6 @@ export default {
|
|
|
198, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70,
|
|
|
60, 50, 40, 30, 20, 10, 1,
|
|
|
],
|
|
|
-
|
|
|
},
|
|
|
],
|
|
|
yAxis: [
|
|
@@ -94,7 +83,7 @@ export default {
|
|
|
],
|
|
|
series: [
|
|
|
{
|
|
|
- name: "压力过低",
|
|
|
+ name: "数据",
|
|
|
type: "bar",
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
@@ -112,7 +101,7 @@ export default {
|
|
|
barWidth: "10",
|
|
|
barCategoryGap: "5%",
|
|
|
data: [
|
|
|
- 23, 66, 76, 12, 79, 42, 15, 56, 13, 29, 20, 4, 22, 12, 38, 9, 31,
|
|
|
+ 99, 66, 76, 12, 79, 42, 15, 56, 13, 29, 20, 4, 22, 12, 38, 9, 31,
|
|
|
66, 90, 77, 14,
|
|
|
],
|
|
|
},
|
|
@@ -154,34 +143,15 @@ export default {
|
|
|
],
|
|
|
},
|
|
|
},
|
|
|
- // {
|
|
|
- // name: '压力超限',
|
|
|
- // type: 'bar',
|
|
|
- // stack: 'pass',
|
|
|
- // emphasis: {
|
|
|
- // focus: 'series'
|
|
|
- // },
|
|
|
- // itemStyle: {
|
|
|
- // color: '#FF0003'
|
|
|
- // },
|
|
|
- // barWidth: '10',
|
|
|
- // barCategoryGap: '5%',
|
|
|
- // data: [220, 182, 191, 234, 290, 330, 310, 120, 132, 101, 134, 90, 230, 210, 4, 5, 6, 3, 2, 1, 4]
|
|
|
- // },
|
|
|
- // {
|
|
|
- // name: '压力正常',
|
|
|
- // type: 'bar',
|
|
|
- // stack: 'pass',
|
|
|
- // emphasis: {
|
|
|
- // focus: 'series'
|
|
|
- // },
|
|
|
- // itemStyle: {
|
|
|
- // color: '#00FE03'
|
|
|
- // },
|
|
|
- // barWidth: '10',
|
|
|
- // barCategoryGap: '5%',
|
|
|
- // data: [150, 232, 201, 154, 190, 330, 4, 5, 6, 3, 2, 1, 4, 410, 120, 132, 101, 134, 90, 230, 210]
|
|
|
- // },
|
|
|
+ {
|
|
|
+ name: "压力过低",
|
|
|
+ type: "line",
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: "#FFFF66",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
],
|
|
|
},
|
|
|
};
|
|
@@ -190,6 +160,23 @@ export default {
|
|
|
console.log(this.$echarts);
|
|
|
this.myChart = this.$echarts.init(document.getElementById("bar"));
|
|
|
this.setBar();
|
|
|
+ let interval = setInterval(() => {
|
|
|
+ let chartData = [];
|
|
|
+ for (let i = 0; i < 21; i++) {
|
|
|
+ chartData.push(this.getRandomNum(0, 120));
|
|
|
+ }
|
|
|
+ this.myChart.setOption({
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: "数据",
|
|
|
+ data: chartData,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ }, 3000);
|
|
|
+ this.$once("hook:beforeDestroy", () => {
|
|
|
+ clearInterval(interval);
|
|
|
+ });
|
|
|
},
|
|
|
methods: {
|
|
|
setBar() {
|
|
@@ -199,5 +186,4 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style>
|
|
|
-</style>
|
|
|
+<style></style>
|