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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<template>
<div class="q-gutter-md overflow-hidden">
<q-virtual-scroll
ref="virtualListRef"
:items="heavyList"
v-slot="{ item, index }"
class="container-height"
:virtual-scroll-slice-ratio-before="1"
:virtual-scroll-slice-ratio-after="0.1"
:virtual-scroll-item-size="600"
:virtual-scroll-sticky-size-start="0"
:virtual-scroll-sticky-size-end="10"
>
<q-item :key="index" v-if="item.id === '1'">
<div class="q-gutter-sm full-width">
<q-btn
unelevated
label="success"
color="positive"
:icon="ICON.success"
@click="onClick('success')"
/>
<q-btn
unelevated
label="error"
color="negative"
:icon="ICON.error"
@click="onClick('error')"
/>
<q-btn
unelevated
label="warn"
color="warning"
:icon="ICON.warn"
@click="onClick('warn')"
/>
<q-btn
unelevated
label="info"
color="info"
:icon="ICON.info"
@click="onClick('info')"
/>
</div>
</q-item>
<q-item :key="index" dense v-if="item.id === '2'">
<div class="q-gutter-sm full-width">
<Com.DateTimePick
style="width: 220px"
v-model="dates"
format24h
:config="{ filled: true, dense: true }"
/>
</div>
</q-item>
<q-item :key="index" dense v-if="item.id === '3'">
<div class="actions full-width">
<div class="q-ml-sm">
<q-btn
round
color="primary"
:icon="ICON.mapLocation"
@click="getLocation"
title="定位"
/>
</div>
<div class="q-mr-sm q-gutter-sm">
<q-btn
v-if="!state.isPlay"
round
color="play"
:icon="ICON.play"
@click="chartRaceRun"
title="开始"
/>
<q-btn
v-else
round
color="pause"
:icon="ICON.pause"
@click="chartRaceStop"
title="停止"
/>
</div>
</div>
</q-item>
<q-item :key="index" dense v-if="item.id === '4'">
<div class="map full-width">
<div class="left-area q-ml-sm" ref="leftMapRef">
<template v-if="state.isRenderMap">
<Com.BaiduMap
id="allmap"
ref="allmapRef"
:scrollWheelZoom="false"
navigationControl
overviewMapControl
scaleControl
:width="state.width"
:height="state.height"
/>
</template>
</div>
<div v class="right-area q-mr-sm">
<!-- 动态排序柱状图 -->
<ChartsRace ref="faChartsRaceRef" />
</div>
</div>
</q-item>
<q-item :key="index" dense v-if="item.id === '5'">
<div class="map full-width">
<div class="left-area q-ml-sm">
<!-- 动态数据 -->
<ChartDynamic />
</div>
<div class="right-area q-mr-sm">
<!-- 时钟 -->
<ChartsClock />
</div>
</div>
</q-item>
<q-item :key="index" dense v-if="item.id === '6'">
<div class="map full-width">
<div class="left-area q-ml-sm">
<!-- 多Y轴示例 -->
<ChartMultipleY />
</div>
<div class="right-area q-mr-sm">
<!-- 联动和共享数据集 -->
<ChartShareDataset />
</div>
</div>
</q-item>
<q-item :key="index" dense v-if="item.id === '7'">
<div class="actions full-width">
<div class="q-ml-sm">
<q-btn color="primary" label="重置图节点" @click="resetChartNode" />
</div>
</div>
</q-item>
<q-item :key="index" dense v-if="item.id === '8'">
<div class="map full-width">
<div class="left-area q-ml-sm">
<!-- 动态增加图节点 -->
<ChartGraphDynamic ref="faGraphDynamicChartRef" />
</div>
<div class="right-area q-mr-sm">2</div>
</div>
</q-item>
<q-item :key="index" dense v-if="index > 7">
<ChartItem :id="`item-chart${item.id}`" />
</q-item>
</q-virtual-scroll>
</div>
</template>
<script lang="ts">
export default {
name: 'PAGE1',
};
</script>
<script lang="ts" setup>
import { ref, reactive, onMounted, nextTick } from 'vue';
import { date, dom } from 'quasar';
import { useMessage } from 'src/common/hooks';
import ICON from 'src/config/icons';
import Com from 'src/components';
import ChartsRace from './elements/ChartsRace.vue';
import ChartDynamic from './elements/ChartDynamic.vue';
import ChartsClock from './elements/ChartsClock.vue';
import ChartMultipleY from './elements/ChartMultipleY.vue';
import ChartShareDataset from './elements/ChartShareDataset.vue';
import ChartGraphDynamic from './elements/ChartGraphDynamic.vue';
import ChartItem from './elements/ChartItem.vue';
// function renewStore() {
// user_store.$patch((state) => {
// state.count++;
// state.arr.push(1);
// });
// user_store.changeState(10);
// }
const { height, width } = dom;
const { success, error, warn, info } = useMessage();
const dates = ref(date.formatDate(Date.now(), 'YYYY/MM/DD HH:mm:ss'));
const virtualListRef = ref<any>(null);
const leftMapRef = ref<any>(null);
const allmapRef = ref<any>(null);
const faChartsRaceRef = ref<any>(null);
const faGraphDynamicChartRef = ref<any>(null);
const state = reactive({
width: 0,
height: 0,
isRenderMap: false,
bMapApi: null as any,
isPlay: true,
});
const heavyList = ref<any>([
{ id: '1' },
{ id: '2' },
{ id: '3' },
{ id: '4' },
{ id: '5' },
{ id: '6' },
{ id: '7' },
{ id: '8' },
]);
onMounted(() => {
for (let index = 0; index < 500; index++) {
heavyList.value.push({
id: String(heavyList.value.length + 1),
});
}
setTimeout(() => {
console.log('宽', width(leftMapRef.value), '高', height(leftMapRef.value));
if (leftMapRef.value) {
state.width = width(leftMapRef.value);
state.height = height(leftMapRef.value) - 2;
state.isRenderMap = true;
nextTick(() => {
state.bMapApi = allmapRef.value.bMapApi;
});
}
}, 500);
});
function onClick(type: string) {
switch (type) {
case 'success':
success('成功');
break;
case 'error':
error('失败');
break;
case 'warn':
warn('警告');
break;
case 'info':
info('提示');
break;
default:
break;
}
}
function getLocation() {
let myCity = new (window as any).BMap.LocalCity();
myCity.get((result: any) => {
const cityName = result.name;
state.bMapApi = allmapRef.value.bMapApi;
state.bMapApi.setCenter(cityName);
});
}
function chartRaceRun() {
state.isPlay = true;
faChartsRaceRef.value.setTimer();
}
function chartRaceStop() {
state.isPlay = false;
faChartsRaceRef.value.clearTimer();
}
function resetChartNode() {
faGraphDynamicChartRef.value.reset();
}
</script>
<style lang="scss" scoped>
.actions {
display: grid;
grid-template-columns: repeat(2, 1fr);
column-gap: $padding-md;
}
.map {
display: grid;
grid-template-columns: repeat(2, 1fr);
column-gap: $padding-md;
> div {
border: 1px solid $border-color;
height: 600px;
}
}
</style>