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
| <template>
| <div ref="chart" style="width: 100%; height: 400px;"></div>
| </template>
|
| <script>
| import * as echarts from 'echarts';
|
| export default {
| name: 'LineChart',
| data() {
| return {
| chartInstance: null,
| threshold: 1.4, // 设置阈值
| };
| },
| mounted() {
| this.initChart();
| },
| beforeUnmount() {
| if (this.chartInstance) {
| this.chartInstance.dispose();
| this.chartInstance = null;
| }
| },
| methods: {
| initChart() {
| const chartDom = this.$refs.chart;
| this.chartInstance = echarts.init(chartDom);
|
| const option = {
| title: {
| text: '营养状态和透析情况',
| left: 'center'
| },
| tooltip: {
| trigger: 'axis'
| },
| xAxis: {
| type: 'category',
| data: ['12:21', '12:22', '12:23', '12:24', '12:25', '12:26', '12:27', '12:28', '12:29', '12:30', '12:31', '12:32', '12:33', '12:34', '12:35', '12:36', '12:37', '12:38']
| },
| yAxis: {
| type: 'value'
| },
| series: [
| {
| data: [1.4, 1.2, 1.4, 1.4, 1.0, 1.4, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.7],
| type: 'line',
| smooth: true,
| color:'red',
| itemStyle: {
| color: function(params) {
| if (params.value > 1.2) {
| return 'red';
| } else {
| return 'blue';
| }
| }.bind(this)
| },
| lineStyle: {
| color: function(params) {
| if (params.value > 1.2) {
| return 'red';
| } else {
| return 'blue';
| }
| }.bind(this)
| }
| }
| ]
| };
|
| this.chartInstance.setOption(option);
| }
| }
| };
| </script>
|
| <style scoped>
| /* 添加一些样式 */
| </style>
|
|