|
@@ -1,104 +1,112 @@
|
|
|
<template>
|
|
|
-<!-- 支架压力柱状图 -->
|
|
|
- <div id="bar" style="height: 250px;width: 300%"></div>
|
|
|
+ <!-- 支架压力柱状图 -->
|
|
|
+ <div id="bar" style="height: 300px; width: 600px;"></div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
- name: 'Bars',
|
|
|
- data(){
|
|
|
+ name: "Bars",
|
|
|
+ data() {
|
|
|
return {
|
|
|
myChart: null,
|
|
|
option: {
|
|
|
tooltip: {
|
|
|
- trigger: 'axis',
|
|
|
+ trigger: "axis",
|
|
|
axisPointer: {
|
|
|
- type: 'shadow'
|
|
|
- }
|
|
|
+ type: "shadow",
|
|
|
+ },
|
|
|
},
|
|
|
- color: ['red', 'green', 'yellow'],
|
|
|
+ color: ["red", "green", "yellow"],
|
|
|
legend: {
|
|
|
- left: 'right',
|
|
|
- icon: 'rect',
|
|
|
+ left: "right",
|
|
|
+ icon: "rect",
|
|
|
textStyle: {
|
|
|
- color: '#000'
|
|
|
+ color: "#000",
|
|
|
},
|
|
|
- data: ['压力超限', '压力过低', '压力正常']
|
|
|
+ data: ["压力超限", "压力过低", "压力正常"],
|
|
|
},
|
|
|
grid: {
|
|
|
- left: '3%',
|
|
|
- right: '4%',
|
|
|
- bottom: '3%',
|
|
|
- containLabel: true
|
|
|
+ left: "3%",
|
|
|
+ right: "4%",
|
|
|
+ bottom: "3%",
|
|
|
+ containLabel: true,
|
|
|
},
|
|
|
xAxis: [
|
|
|
{
|
|
|
- type: 'category',
|
|
|
- data: [198, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 ,1]
|
|
|
- }
|
|
|
+ type: "category",
|
|
|
+ data: [
|
|
|
+ 198, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70,
|
|
|
+ 60, 50, 40, 30, 20, 10, 1,
|
|
|
+ ],
|
|
|
+ },
|
|
|
],
|
|
|
yAxis: [
|
|
|
{
|
|
|
- type: 'value'
|
|
|
- }
|
|
|
+ type: "value",
|
|
|
+ },
|
|
|
],
|
|
|
series: [
|
|
|
{
|
|
|
- name: '压力过低',
|
|
|
- type: 'bar',
|
|
|
+ name: "压力过低",
|
|
|
+ type: "bar",
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
|
- color: function(params){
|
|
|
- if(params.data > 64){
|
|
|
- return 'red';
|
|
|
- } else if (params.data < 24){
|
|
|
- return 'green';
|
|
|
- } else {
|
|
|
- return 'yellow'
|
|
|
+ color: function (params) {
|
|
|
+ if (params.data > 64) {
|
|
|
+ return "red";
|
|
|
+ } else if (params.data < 24) {
|
|
|
+ return "green";
|
|
|
+ } else {
|
|
|
+ return "yellow";
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- barWidth: '10',
|
|
|
- barCategoryGap: '5%',
|
|
|
- data: [23, 66, 76, 12, 79, 42, 15, 56, 13, 29, 20, 4, 22, 12, 38, 9, 31, 66, 90, 77, 14]
|
|
|
+ barWidth: "10",
|
|
|
+ barCategoryGap: "5%",
|
|
|
+ data: [
|
|
|
+ 23, 66, 76, 12, 79, 42, 15, 56, 13, 29, 20, 4, 22, 12, 38, 9, 31,
|
|
|
+ 66, 90, 77, 14,
|
|
|
+ ],
|
|
|
},
|
|
|
- { //这两组数据用来模拟markLine线段开关,data可以为空
|
|
|
- name:'压力超限',
|
|
|
- type:'line',
|
|
|
- markLine:{
|
|
|
- data:[
|
|
|
+ {
|
|
|
+ //这两组数据用来模拟markLine线段开关,data可以为空
|
|
|
+ name: "压力超限",
|
|
|
+ type: "line",
|
|
|
+ markLine: {
|
|
|
+ data: [
|
|
|
{
|
|
|
- name:'压力超限',
|
|
|
- yAxis:"64",
|
|
|
- itemStyle:{
|
|
|
- normal:{
|
|
|
- show: true,
|
|
|
- color:'red'
|
|
|
- }
|
|
|
+ name: "压力超限",
|
|
|
+ yAxis: "64",
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ show: true,
|
|
|
+ color: "red",
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
- { //这两组数据用来模拟markLine线段开关,data可以为空
|
|
|
- name:'压力正常',
|
|
|
- type:'line',
|
|
|
- markLine:{
|
|
|
- data:[
|
|
|
- {
|
|
|
- name:'压力正常',
|
|
|
- yAxis:"24",
|
|
|
- itemStyle:{
|
|
|
- normal:{
|
|
|
- show:true,
|
|
|
- color:'yellow'
|
|
|
- }
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ //这两组数据用来模拟markLine线段开关,data可以为空
|
|
|
+ name: "压力正常",
|
|
|
+ type: "line",
|
|
|
+ markLine: {
|
|
|
+ data: [
|
|
|
+ {
|
|
|
+ name: "压力正常",
|
|
|
+ yAxis: "24",
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ show: true,
|
|
|
+ color: "yellow",
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
// {
|
|
|
// name: '压力超限',
|
|
|
// type: 'bar',
|
|
@@ -127,23 +135,22 @@ export default {
|
|
|
// barCategoryGap: '5%',
|
|
|
// data: [150, 232, 201, 154, 190, 330, 4, 5, 6, 3, 2, 1, 4, 410, 120, 132, 101, 134, 90, 230, 210]
|
|
|
// },
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ };
|
|
|
},
|
|
|
mounted() {
|
|
|
- console.log(this.$echarts)
|
|
|
- this.myChart = this.$echarts.init(document.getElementById('bar'));
|
|
|
+ console.log(this.$echarts);
|
|
|
+ this.myChart = this.$echarts.init(document.getElementById("bar"));
|
|
|
this.setBar();
|
|
|
},
|
|
|
methods: {
|
|
|
setBar() {
|
|
|
- this.myChart.setOption(this.option)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ this.myChart.setOption(this.option);
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
-
|
|
|
</style>
|