11import { rgb } from "d3" ;
2- import { isObject } from "./options.js" ;
2+ import { isScaleOptions } from "./options.js" ;
33import { normalizeScale } from "./scales.js" ;
44import { legendRamp } from "./legends/ramp.js" ;
55import { legendSwatches , legendSymbols } from "./legends/swatches.js" ;
@@ -13,17 +13,17 @@ const legendRegistry = new Map([
1313export function legend ( options = { } ) {
1414 for ( const [ key , value ] of legendRegistry ) {
1515 const scale = options [ key ] ;
16- if ( isObject ( scale ) ) { // e.g., ignore {color: "red"}
16+ if ( isScaleOptions ( scale ) ) { // e.g., ignore {color: "red"}
1717 let hint ;
1818 // For symbol legends, pass a hint to the symbol scale.
1919 if ( key === "symbol" ) {
20- const { fill, stroke = fill === undefined && isObject ( options . color ) ? "color" : undefined } = options ;
20+ const { fill, stroke = fill === undefined && isScaleOptions ( options . color ) ? "color" : undefined } = options ;
2121 hint = { fill, stroke} ;
2222 }
2323 return value (
2424 normalizeScale ( key , scale , hint ) ,
2525 legendOptions ( scale , options ) ,
26- key => isObject ( options [ key ] ) ? normalizeScale ( key , options [ key ] ) : null
26+ key => isScaleOptions ( options [ key ] ) ? normalizeScale ( key , options [ key ] ) : null
2727 ) ;
2828 }
2929 }
0 commit comments