Skip to content

Commit 1d28494

Browse files
committed
feat(globe): enhance traffic visualization effects
Improves the visual representation of traffic events on the globe: - Optimizes arc animation parameters for smoother transitions - Adds source and target ring animations for better event tracking - Skips visualization for nearby locations to reduce visual clutter - Updates color scheme to dark orange for better visibility - Synchronizes animation timings with event delays
1 parent 06fb156 commit 1d28494

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

app/components/dashboard/realtime/Globe.vue

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,37 @@ function trafficEvent({ props }, { delay = 0 }) {
7474
startLng: props.item.longitude,
7575
endLat: colos.value[props.item.COLO]?.lat,
7676
endLng: colos.value[props.item.COLO]?.lon,
77-
color: 'red',
78-
arcAltitude: 0.5,
77+
color: 'darkOrange',
78+
arcAltitude: 0.2,
79+
}
80+
console.info(`from ${props.item.city}(${arc.startLat}, ${arc.startLng}) to ${props.item.COLO}(${arc.endLat}, ${arc.endLng})`)
81+
const isNear = Math.abs(arc.endLat - arc.startLat) < 5 && Math.abs(arc.endLng - arc.startLng) < 5
82+
if (isNear) {
83+
console.info(`from ${props.item.city} to ${props.item.COLO} is near, skip`)
84+
return
7985
}
80-
console.info(`from ${props.item.city}(${props.item.latitude}, ${props.item.longitude}) to ${props.item.COLO}(${colos.value[props.item.COLO]?.lat}, ${colos.value[props.item.COLO]?.lon})`)
8186
const random = Math.random()
8287
globe.arcsData([arc])
8388
.arcColor('color')
84-
.arcDashLength(() => random + 0.2)
85-
.arcDashGap(() => random - 0.2)
86-
.arcDashAnimateTime(2000)
89+
.arcDashLength(() => random)
90+
.arcDashGap(() => 1 - random)
91+
.arcDashAnimateTime(delay * 2)
92+
.ringRepeatPeriod(delay * 2)
93+
94+
const srcRing = { lat: arc.startLat, lng: arc.startLng }
95+
globe.ringsData([...globe.ringsData(), srcRing])
96+
setTimeout(() => globe.ringsData(globe.ringsData().filter(r => r !== srcRing)), delay * 2)
97+
98+
setTimeout(() => {
99+
const targetRing = { lat: arc.endLat, lng: arc.endLng }
100+
globe.ringsData([...globe.ringsData(), targetRing])
101+
setTimeout(() => globe.ringsData(globe.ringsData().filter(r => r !== targetRing)), delay * 2)
102+
}, delay * 2)
87103
88104
clearTimeout(cleanArcsDataTimer)
89105
cleanArcsDataTimer = setTimeout(() => {
90106
globe.arcsData([])
91-
}, delay + 100)
107+
}, delay * 2)
92108
}
93109
94110
const normalized = 5 / props.minutes
@@ -114,6 +130,9 @@ function initGlobe() {
114130
.hexBinMerge(true)
115131
.hexBinPointWeight('count')
116132
.hexPolygonColor(() => `rgba(54, 211, 153, ${Math.random() / 1.5 + 0.5})`)
133+
.ringColor(() => t => `rgba(255,100,50,${1 - t})`)
134+
.ringMaxRadius(3)
135+
.ringPropagationSpeed(3)
117136
.onGlobeReady(() => {
118137
globe.pointOfView({ lat: currentLocation.value.latitude, lng: currentLocation.value.longitude, altitude: width.value > 768 ? 2 : 3 })
119138
globe.controls().autoRotate = true

0 commit comments

Comments
 (0)