File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -69,18 +69,30 @@ const computeColorSegments = (
6969 }
7070
7171 // station.lines と trainType.lines の路線IDを照合して色を決定
72- const stationColors = stations . map ( ( s ) => {
73- if ( ! s ) return fallbackColor ;
72+ // マッチしない駅は null にして隣接する確定色で埋める
73+ const resolvedColors : ( string | null ) [ ] = stations . map ( ( s ) => {
74+ if ( ! s ) return null ;
7475
7576 for ( const ttLine of trainTypeLines ) {
7677 if ( s . lines ?. some ( ( sl ) => sl . id === ttLine . id ) ) {
77- return ttLine . color ?? fallbackColor ;
78+ return ttLine . color ?? null ;
7879 }
7980 }
8081
81- return s . line ?. color ?? fallbackColor ;
82+ // trainTypeLinesが空なら駅固有の色を使用
83+ return trainTypeLines . length > 0 ? null : ( s . line ?. color ?? null ) ;
8284 } ) ;
8385
86+ // null を隣接する確定色で埋める(前方 → 後方の順)
87+ for ( let i = 1 ; i < resolvedColors . length ; i ++ ) {
88+ if ( resolvedColors [ i ] === null ) resolvedColors [ i ] = resolvedColors [ i - 1 ] ;
89+ }
90+ for ( let i = resolvedColors . length - 2 ; i >= 0 ; i -- ) {
91+ if ( resolvedColors [ i ] === null ) resolvedColors [ i ] = resolvedColors [ i + 1 ] ;
92+ }
93+
94+ const stationColors = resolvedColors . map ( ( c ) => c ?? fallbackColor ) ;
95+
8496 // 駅のドットy座標(スクリーン座標)
8597 const dotYs = stations . map ( ( _ , i ) =>
8698 i === 0 ? height / 30 : ( i * height ) / 7
You can’t perform that action at this time.
0 commit comments