You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, only fixed colors or color scales in PREDEFINED_COLOR_STR_MAP are supported. It would be great if we could extend this to support arbitrary range, like ["green", "red", "blue"] or so.
A very simple (and possibly incomplete) implementation in gosling-track-model.ts could look like this:
letinterpolate=interpolateViridis;if(Object.keys(PREDEFINED_COLOR_STR_MAP).includes(rangeasstring)){interpolate=PREDEFINED_COLOR_STR_MAP[rangeasstring];}elseif(Array.isArray(range)&&range.every(d=>typeofd==='string')){// Support for custom color palettes, i.e. ["green", "red", "blue"]constscaler=scaleLinear(rangeasstring[]).domain(// Map the range to [0, 0.5, 1] in the above examplerange.map((_,i,arr)=>i/(arr.length-1)));interpolate=(t: number)=>scaler(t);}this.channelScales[channelKey]=scaleSequential(interpolate).domain(domainas[number,number]);break;
Note that this assume that the domain remains a [number, number], hence we interpolate all colors (even more than 2) linearly between the domain. If we want to support [string, string, string] as range and [number, number, number] as domain, more adjustments are required.
The text was updated successfully, but these errors were encountered:
Currently, only fixed colors or color scales in
PREDEFINED_COLOR_STR_MAP
are supported. It would be great if we could extend this to support arbitrary range, like["green", "red", "blue"]
or so.A very simple (and possibly incomplete) implementation in
gosling-track-model.ts
could look like this:Note that this assume that the
domain
remains a[number, number]
, hence we interpolate all colors (even more than 2) linearly between the domain. If we want to support[string, string, string]
as range and[number, number, number]
as domain, more adjustments are required.The text was updated successfully, but these errors were encountered: