@@ -310,27 +310,22 @@ export default function App() {
310
310
renderMode : showTrips ? 'trips' : 'paths' ,
311
311
uniqueIdProperty : 'trajectoryId' , // TODO internalize this
312
312
313
- // Color entire line by trajectoryId
314
- //_getLineColor: colorContinuous({
315
- // attr: 'trajectoryId',
316
- // domain: [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],
317
- // colors: palette
318
- //}),
319
- getLineColor : ( d : any , info : any ) => {
320
- //return [255 * Math.random(), 255 * Math.random(), 255 * Math.random(), 255];
321
- const { data, index } = info ;
322
- const nVertices = data . startIndices [ index + 1 ] - data . startIndices [ index ] ;
323
- const colors = new Array ( nVertices ) . fill ( 0 ) . map ( ( _ , i ) => {
324
- return [ 255 * Math . random ( ) , 255 * Math . random ( ) , 255 * Math . random ( ) , 255 ] ;
325
- } ) ;
313
+ // Color entire line by trajectoryId, will be invoked once per line
314
+ getLineColor : colorContinuous ( {
315
+ attr : 'trajectoryId' ,
316
+ domain : [ 0 , 100 , 200 , 300 , 400 , 500 , 600 , 700 , 800 , 900 , 1000 ] ,
317
+ colors : palette
318
+ } ) ,
326
319
327
- // Return an array to color each vertex
328
- return colors ;
320
+ // Color each vertex, will be invoked once per vertex
321
+ getFillColor : ( d : any , info : any ) => {
322
+ return [ 255 * Math . random ( ) , 255 * Math . random ( ) , 255 * Math . random ( ) , 255 ] ;
329
323
} ,
330
324
331
325
326
+
332
327
// Alternative API, dedicated accessor: Color each vertex by speed
333
- getVertexColor : colorContinuous ( {
328
+ _getVertexColor : colorContinuous ( {
334
329
attr : ( d : any ) => d . speed ,
335
330
domain : [ 5 , 7 , 9 , 11 , 13 , 15 ] ,
336
331
colors : palette
@@ -396,20 +391,6 @@ export default function App() {
396
391
< ObjectSelect title = "Map Style" obj = { MAP_STYLES } value = { mapStyle } onSelect = { setMapStyle } top = { 60 } />
397
392
< ObjectSelect title = "Palette" obj = { PALETTES } value = { palette } onSelect = { setPalette } top = { 90 } />
398
393
< ObjectSelect title = "Outline" obj = { OUTLINES } value = { outline } onSelect = { setOutline } top = { 120 } />
399
- { clickedTrajectoryId && (
400
- < div style = { {
401
- position : 'absolute' ,
402
- right : 2 ,
403
- top : 150 ,
404
- background : 'rgba(0,0,0,0.8)' ,
405
- color : 'white' ,
406
- padding : '4px 8px' ,
407
- borderRadius : '4px' ,
408
- fontSize : '12px'
409
- } } >
410
- 📍 Following: { clickedTrajectoryId }
411
- </ div >
412
- ) }
413
394
{ showTrips && < RangeInput
414
395
name = { 'Time' }
415
396
animationSpeed = { animationSpeed }
@@ -447,19 +428,21 @@ export default function App() {
447
428
onChange = { setLineWidth }
448
429
formatLabel = { ( x : number ) => formatLabel ( x , 'pixels' ) }
449
430
/>
450
- < div style = { {
451
- position : 'absolute' ,
452
- left : 10 ,
453
- bottom : 10 ,
454
- background : 'rgba(0,0,0,0.7)' ,
455
- color : 'white' ,
456
- padding : '8px' ,
457
- borderRadius : '4px' ,
458
- fontSize : '12px' ,
459
- maxWidth : '300px'
460
- } } >
461
- 💡 Click any trajectory to jump to its start time
462
- </ div >
431
+ { showTrips && (
432
+ < div style = { {
433
+ position : 'absolute' ,
434
+ left : 10 ,
435
+ bottom : 10 ,
436
+ background : 'rgba(0,0,0,0.7)' ,
437
+ color : 'white' ,
438
+ padding : '8px' ,
439
+ borderRadius : '4px' ,
440
+ fontSize : '12px' ,
441
+ maxWidth : '300px'
442
+ } } >
443
+ 💡 Click any trajectory to jump to its start time
444
+ </ div >
445
+ ) }
463
446
</ >
464
447
) ;
465
448
}
0 commit comments