@@ -351,6 +351,8 @@ function mergeOptions(defaultOptions, themeOptionsKey, userOptions) {
351
351
function getColorScale ( colorScheme , customColors , uniqueGroups ) {
352
352
let colorScale ;
353
353
354
+ //customColors = { ...(customColors || {}), null: "#FFF" };
355
+
354
356
const schemeCategory30 = [
355
357
"#1f77b4" , "#ff7f0e" , "#2ca02c" , "#d62728" , "#9467bd" ,
356
358
"#8c564b" , "#e377c2" , "#7f7f7f" , "#bcbd22" , "#17becf" ,
@@ -360,18 +362,9 @@ function getColorScale(colorScheme, customColors, uniqueGroups) {
360
362
"#8c6d31" , "#e7cb94" , "#e7969c" , "#7b4173" , "#a55194"
361
363
] ;
362
364
363
- if ( customColors && typeof customColors === "string" ) {
364
- // Handle customColors as a single color
365
- colorScale = d3 . scaleOrdinal ( )
366
- . domain ( uniqueGroups )
367
- . range ( uniqueGroups . map ( ( ) => customColors ) ) ;
368
- } else if ( customColors && Array . isArray ( customColors ) ) {
369
- // Handle customColors as an array
370
- colorScale = d3 . scaleOrdinal ( )
371
- . domain ( uniqueGroups )
372
- . range ( uniqueGroups . map ( ( group , index ) => customColors [ index % customColors . length ] || "#FFF" ) ) ;
373
- } else if ( customColors && typeof customColors === 'object' ) {
374
- // Handle customColors as an object
365
+ // Check if customColors is an object and not an array
366
+ if ( customColors && typeof customColors === 'object' && ! Array . isArray ( customColors ) ) {
367
+ // Create a color scale based on the customColors object
375
368
colorScale = d3 . scaleOrdinal ( )
376
369
. domain ( uniqueGroups )
377
370
. range ( uniqueGroups . map ( group => customColors [ group ] || "#FFF" ) ) ;
@@ -388,18 +381,15 @@ function getColorScale(colorScheme, customColors, uniqueGroups) {
388
381
}
389
382
}
390
383
} else {
391
- // Default to schemeCategory30
392
384
colorScale = d3 . scaleOrdinal ( schemeCategory30 )
393
385
. domain ( uniqueGroups )
394
386
. range ( uniqueGroups . map ( group =>
395
387
group === "No Hit" || group === null ? "#FFF" : schemeCategory30 [ uniqueGroups . indexOf ( group ) % schemeCategory30 . length ]
396
388
) ) ;
397
389
}
398
-
399
390
return colorScale ;
400
391
}
401
392
402
-
403
393
function isInAnyDiscontinuity ( value , breaks ) {
404
394
for ( let gap of breaks ) {
405
395
if ( value >= gap . start && value <= gap . end ) {
0 commit comments