1
- import { isNoneish , map , number , valueof } from "../options.js" ;
1
+ import { map , number , valueof } from "../options.js" ;
2
2
import { applyPosition } from "../projection.js" ;
3
3
import { sqrt3 } from "../symbol.js" ;
4
4
import { initializer } from "./basic.js" ;
@@ -13,17 +13,19 @@ export const ox = 0.5,
13
13
oy = 0 ;
14
14
15
15
export function hexbin ( outputs = { fill : "count" } , { binWidth, ...options } = { } ) {
16
+ const { z} = options ;
17
+
16
18
// TODO filter e.g. to show empty hexbins?
17
19
// TODO disallow x, x1, x2, y, y1, y2 reducers?
18
20
binWidth = binWidth === undefined ? 20 : number ( binWidth ) ;
19
21
outputs = maybeOutputs ( outputs , options ) ;
20
22
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 : [ ] } } ;
27
29
28
30
// Populate default values for the r and symbol options, as appropriate.
29
31
if ( options . symbol === undefined ) options . symbol = "hexagon" ;
0 commit comments