Repository navigation
fix(event-display): support 1D linkedTracks in colorTracksByVertex - #1074
RuhaaBhalerao wants to merge 1 commit into
Conversation
|
🚀 Preview deployed: http://phoenix-pr-1074.surge.sh Built from 6c83b83. |
|
Hi @EdwardMoyse, Following up on the vertex coloring discussion in #948 and #977, I noticed that while #977 added support for multi-collection 2D linkedTracks (number[][]), loaders like JiveXMLLoader and legacy event datasets store linkedTracks as a 1D array of indices (number[]) and linkedTrackCollection as a string. When choosing "Color by → Vertex" on JiveXML data, linkedTracks[collectionIndex] evaluates to a number rather than an array, causing an unhandled TypeError: linkedTracks[collectionIndex].forEach is not a function. This PR updates colorTracksByVertex to defensively support both 1D and 2D linkedTracks representations (and exact string matches for linkedTrackCollection), and adds unit tests covering both formats. Whenever you have a chance, I'd appreciate your review! |
Summary of Changes
In #977,
linkedTrackCollectionwas extended to an array of collection names (string[]) andlinkedTracksto an array of track index lists (number[][]) to support vertices linking across multiple track collections.However, loaders such as
JiveXMLLoaderand existing/legacy event datasets storelinkedTrackCollectionas a singlestring(e.g.'Tracks') andlinkedTracksas a 1D list of track indices (e.g.[0, 1, 2]).When a user selects "Color by → Vertex" on such events:
linkedTrackCollection.indexOf(collectionName)returns0.linkedTracks[collectionIndex]evaluates tolinkedTracks[0], which is the first track index (number), rather than an array.linkedTracks[collectionIndex].forEach(...)immediately throws an uncaught exception:TypeError: linkedTracks[collectionIndex].forEach is not a function.linkedTrackCollection?.includes(collectionName)on a string matched substrings (e.g.'Tracks'matched'ack'), causing wrong collection indices to be computed.Changes:
ColorManager.colorTracksByVertex:number[][]) and 1D (number[])linkedTracksstructures cleanly.linkedTrackCollection === collectionName) whenlinkedTrackCollectionis a string to prevent false-positive substring matches.Testing
color-manager.test.ts:linkedTracksis a 2D array ([['Tracks']],[[0]]).linkedTracksis a 1D array ('Tracks',[0]) without throwingTypeError.