mh-two-thousand-and-two
2024-04-03 29a02350b873fa6339a7535fa929697fec9a8f84
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template >
    <view >
        <!-- 顶部导航 -->
        <headNav :idIndex="idIndex" text="历代学术流派"/>
    <!-- 学派 -->
        <view class="flex flex-center" style="width: 100%; margin: .2rem 0;">
            <ul class="flex">
                <li style="" v-for="(item,index) in dynasty" :key="item.id">
                    <view @click="SchoolClick(item.id)" class="flex flex-center font-family school"
                        :style="{'marginRight': index === dynasty.length - 1 ? '0' : '0.03rem'}"
                        style="font-weight: 500; border-radius: .3rem; padding: .06rem .15rem; color: #2C2C2C; font-size: .12rem; margin-top: .03rem;margin-right: .1rem;background-color: #fff;">
                        <view class="" :style="{background:item.color}" style="margin-right: .07rem; width: .12rem;height: .12rem;border-radius: 50%;"></view>
                        <view class="" style="color: #2C2C2C;font-size: .12rem;">{{item.name}}</view>
                    </view>
                </li>
            </ul>
        </view>
        <view class="" style="background-color: #fff;">
            <view id="line-chart" style="width: 100vw;"></view>
        </view>
    </view>
</template>
 
<script>
    import * as echarts from 'echarts';
    import axios from 'axios';
    export default {
        data() {
            return {
                // 标题顶部栏需要的东西
                idIndex:0,
                // 朝代
                dynasty: [{
                    name: '医经学派',
                    color: '#90BBD8',
                    id: 1
                }, {
                    name: '经方学派',
                    color: '#EDD28B',
                    id: 2
                }, {
                    name: '伤寒学派',
                    color: '#CF746D',
                    id: 3
                },{
                    name: '河间学派',
                    color: '#9CC27A',
                    id: 4
                }, {
                    name: '攻邪学派',
                    color: '#5B6CB9',
                    id:5
                }, {
                    name: '滋阴学派',
                    color: '#8860A8',
                    id: 6
                }, {
                    name: '易水学派',
                    color: '#DE8E66',
                    id: 7
                }, {
                    name: '温补学派',
                    color: '#7FAC8C',
                    id: 8
                }],
                chartData: [{
                    name: '你好',
                    values: [30, 10, 100, 400, 30, 70]
                },{
                    name: '你w好',
                    values: [23, 30, 140, 200, 230, 470]
                }]
            }
        }, 
        onLoad(options) {
            this.idIndex = options.id
            console.log('optionsoptionsoptions',options.id);
        },
        methods: {
            // 
            SchoolClick(id){
                console.log(id);
                uni.navigateTo({
                    url:'/pages/interchannel/interchannel?id='+this.idIndex
                })
            },
            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),
                    // },
                    zoom: 8,// 这里可以根据需要调整缩放级别
                    
                    xAxis: {
                        type: 'category',
                        data: xAxisData,
                        axisLabel: {
                              fontSize: 32 // 设置 x 轴上文字的字体大小为 12 像素
                            },
                             axisLine: {
                                  lineStyle: {
                                    width: 4 // 设置x轴线条宽度为2像素
                                  }
                                }
                    },
                    yAxis: {
                        type: 'value',
                        axisLabel: {
                              fontSize: 32 // 设置 x 轴上文字的字体大小为 12 像素
                            },
                             axisLine: {
                                  lineStyle: {
                                    width: 10 // 设置x轴线条宽度为2像素
                                  }
                                }
                    },
                    series: series,
                     // 其他配置项...
                      textStyle: {
                        fontSize: 30 // 设置全局文字的字体大小
                      },
                };
 
                chart.setOption(option);
            }
        },
        mounted() {
            this.renderChart();
        }
    }
</script>
 
<style>
    view {
        color: #fff;
    }
    .school{
        
    }
    .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;
        }
    }
    #line-chart{
        height: 6rem;
    }
</style>