@@ -3,6 +3,7 @@ import {isColor, isEvery, isOrdinal, isFirst, isTemporal, isTemporalString, isNu
33import { registry , color , position , radius , opacity , symbol , length } from "./scales/index.js" ;
44import { ScaleLinear , ScaleSqrt , ScalePow , ScaleLog , ScaleSymlog , ScaleQuantile , ScaleQuantize , ScaleThreshold , ScaleIdentity } from "./scales/quantitative.js" ;
55import { ScaleDiverging , ScaleDivergingSqrt , ScaleDivergingPow , ScaleDivergingLog , ScaleDivergingSymlog } from "./scales/diverging.js" ;
6+ import { isDivergingScheme } from "./scales/schemes.js" ;
67import { ScaleTime , ScaleUtc } from "./scales/temporal.js" ;
78import { ScaleOrdinal , ScalePoint , ScaleBand , ordinalImplicit } from "./scales/ordinal.js" ;
89import { isSymbol , maybeSymbol } from "./symbols.js" ;
@@ -212,7 +213,7 @@ function formatScaleType(type) {
212213 return typeof type === "symbol" ? type . description : type ;
213214}
214215
215- function inferScaleType ( key , channels , { type, domain, range, scheme} ) {
216+ function inferScaleType ( key , channels , { type, domain, range, scheme, pivot } ) {
216217 // The facet scales are always band scales; this cannot be changed.
217218 if ( key === "fx" || key === "fy" ) return "band" ;
218219
@@ -266,13 +267,15 @@ function inferScaleType(key, channels, {type, domain, range, scheme}) {
266267 if ( domain !== undefined ) {
267268 if ( isOrdinal ( domain ) ) return asOrdinalType ( kind ) ;
268269 if ( isTemporal ( domain ) ) return "utc" ;
270+ if ( kind === color && ( pivot != null || isDivergingScheme ( scheme ) ) ) return "diverging" ;
269271 return "linear" ;
270272 }
271273
272274 // If any channel is ordinal or temporal, it takes priority.
273275 const values = channels . map ( ( { value} ) => value ) . filter ( value => value !== undefined ) ;
274276 if ( values . some ( isOrdinal ) ) return asOrdinalType ( kind ) ;
275277 if ( values . some ( isTemporal ) ) return "utc" ;
278+ if ( kind === color && ( pivot != null || isDivergingScheme ( scheme ) ) ) return "diverging" ;
276279 return "linear" ;
277280}
278281
0 commit comments