mh-two-thousand-and-two
2024-03-29 d27fbd63d7840787d7f3ca5333b6e24dc3a860d4
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
    <view>
        <view class="NavTop flex">
            <view class=""><img src="../../static/中医人物知识库0201/三条杠.png" alt="" /></view>
            <view class="">历代学术流派</view>
            <view class="NavTopr">
                <img src="../../static/中医人物知识库0201/三条杠.png" alt="" />
                <img src="../../static/中医人物知识库0201/三条杠.png" alt="" />
                <img src="../../static/中医人物知识库0201/三条杠.png" alt="" />
            </view>
        </view>
        <view class="mImage">
            <img src="https://img0.baidu.com/it/u=3838093562,4126749835&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1710522000&t=a986064700deada5ec74d05e02abd8b5"
                alt="" />
        </view>
 
        <view class="">
            <view id="line-chart" style="width: 100vw;height: 500px;"></view>
        </view>
    </view>
</template>
 
<script>
    import * as echarts from 'echarts';
    import axios from 'axios';
    export default {
        data() {
            return {
                chartData: [{
                    name: '你好',
                    values: [30, 10, 100, 400, 30, 70]
                },{
                    name: '你w好',
                    values: [23, 30, 140, 200, 230, 470]
                }]
            }
        }, 
        methods: {
            renderChart() {
                const chart = echarts.init(document.getElementById('line-chart'));
                const xAxisData = ['1950', '1955', '1960', '1965', '1970', '1975', '123'];
                console.log(this.chartData);
                // 暂存一下
                let chartData1 = this.chartData
                const series = this.chartData.map((item, i) => {
                    return {
                        name: item.name,
                        type: 'line',
                        data: item.values,
                        smooth: 0.5,
                        label: {
                            show: true, // 显示标签
                            position: 'right', // 标签位置:右侧
                            formatter: function(param) {
                                if (chartData1[i].values.length - 1 === param.dataIndex) {
                                    console.log(param);
                                    return param.seriesName + ' : '+ param.value;
                                }else{
                                    return ''
                                }
 
                            }
                        }
                    };
                });
 
                const option = {
                    legend: {
                        data: this.chartData.map(item => item.name),
                    },
                    xAxis: {
                        type: 'category',
                        data: xAxisData,
                    },
                    yAxis: {
                        type: 'value',
                    },
                    series: series,
                };
 
                chart.setOption(option);
            }
        },
        mounted() {
            this.renderChart();
        }
    }
</script>
 
<style>
    view {
        color: #fff;
    }
 
    .bag {
        height: 100vh;
        background-color: #fff;
    }
 
    .NavTop {
        background-color: #0c274c;
        padding: 25rpx;
 
        img {
            width: 30rpx;
            height: 30rpx;
            vertical-align: middle;
        }
 
        .NavTopr {
            img {
                margin-right: 10rpx;
            }
        }
    }
 
    .mImage {
        width: 100%;
        height: 40rpx;
 
        img {
            vertical-align: top;
        }
    }
</style>