1- import { isNoneish , map , number , valueof } from "../options.js" ;
1+ import { map , number , valueof } from "../options.js" ;
22import { applyPosition } from "../projection.js" ;
33import { sqrt3 } from "../symbol.js" ;
44import { initializer } from "./basic.js" ;
@@ -13,17 +13,19 @@ export const ox = 0.5,
1313 oy = 0 ;
1414
1515export function hexbin ( outputs = { fill : "count" } , { binWidth, ...options } = { } ) {
16+ const { z} = options ;
17+
1618 // TODO filter e.g. to show empty hexbins?
1719 // TODO disallow x, x1, x2, y, y1, y2 reducers?
1820 binWidth = binWidth === undefined ? 20 : number ( binWidth ) ;
1921 outputs = maybeOutputs ( outputs , options ) ;
2022
21- // A fill output means a fill channel, and hence the stroke should default to
22- // none (assuming a mark that defaults to fill and no stroke, such as dot).
23- // Note that it’s safe to mutate options here because we just created it with
24- // the rest operator above.
25- const { z , fill , stroke } = options ;
26- if ( stroke === undefined && isNoneish ( fill ) && hasOutput ( outputs , "fill" ) ) options . stroke = "none" ;
23+ // A fill output means a fill channel; declaring the channel here instead of
24+ // waiting for the initializer allows the mark constructor to determine that
25+ // the stroke should default to none (assuming a mark that defaults to fill
26+ // and no stroke, such as dot). Note that it’s safe to mutate options here
27+ // because we just created it with the rest operator above.
28+ if ( hasOutput ( outputs , "fill" ) ) options . channels = { ... options . channels , fill : { value : [ ] } } ;
2729
2830 // Populate default values for the r and symbol options, as appropriate.
2931 if ( options . symbol === undefined ) options . symbol = "hexagon" ;
0 commit comments