1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
| <!--
| * @Date: 2024-04-18 21:52:18
| * @LastEditors: Sneed
| * @LastEditTime: 2024-06-20 23:37:09
| * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/components/TimeAlarm.vue
| -->
| <template>
| <div ref="processCharts" style="width: 100%;height:32px;" id="record"></div>
| </template>
|
| <script>
| import * as echarts from 'echarts';
| export default {
| data() {
| return {
| option: {
| // tooltip: {
| // trigger: 'axis',
| // axisPointer: {
| // type: 'shadow'
| // }
| // },
| grid: {
| left: 0,
| right: 0,
| width: "100%"
| },
| xAxis: {
| type: 'value',
| min: 0,
| max: 24, // 根据需要调整最大值
| axisLabel: {
| show: false,
| margin: 0
| },
| splitLine: {
| show: false
| },
| minorSplitLine: {
| show: false
| },
| splitArea: {
| show: false
| },
| axisTick: {
| show: false
| },
| boundaryGap: false, // 留出一点空间
| },
| yAxis: {
| type: 'category',
| data: ['柱子'],
| show: false
| },
| series: []
| }
| }
| },
| methods: {
|
| },
| mounted() {
| // this.option.series = [
| // {name: '空闲时间',type: 'bar',stack: 'total',itemStyle: {color: '#fdff85'},data: [2]},
| // {name: '工作时间',type: 'bar',stack: 'total',itemStyle: {color: '#307f45'},data: [3]}
| // ]
| var arr = [];
| for(var i=0;i<24;i++) {
| var obj = {name: '空闲时间',type: 'bar',stack: 'total',barCategoryGap: '0',barGap: '-100%',itemStyle: {color: '#fdff85'},data: [1]};
| if(Math.random() >= 0.5) {
| obj.itemStyle.color = "#fdff85";
| }else {
| obj.itemStyle.color = "#307f45";
| }
| arr.push(obj)
| }
| this.option.series = arr;
| console.log(this.option.series)
| var recordDom = this.$refs.processCharts;
| var myChart = echarts.init(recordDom);
| myChart.setOption(this.option);
| },
| }
| </script>
|
| <style lang="scss" scoped></style>
|
|