@@ -22,7 +22,7 @@ export function group({x, y, out = "fill", ...options} = {}) {
2222}
2323
2424function group1 ( x = identity , { domain, normalize, z, fill, stroke, ...options } = { } ) {
25- const k = normalize === true ? 100 : + normalize ;
25+ const k = normalize === true || normalize === "z" ? 100 : + normalize ;
2626 const [ X , setX ] = lazyChannel ( x ) ;
2727 const [ Y , setY ] = lazyChannel ( `Frequency${ k === 100 ? " (%)" : "" } ` ) ;
2828 const [ Z , setZ ] = maybeLazyChannel ( z ) ;
@@ -50,11 +50,12 @@ function group1(x = identity, {domain, normalize, z, fill, stroke, ...options} =
5050 const BZ = Z && setZ ( [ ] ) ;
5151 const BF = F && setF ( [ ] ) ;
5252 const BS = S && setS ( [ ] ) ;
53- const n = data . length ;
53+ let n = data . length ;
5454 let i = 0 ;
5555 for ( const facet of facets ) {
5656 const groupFacet = [ ] ;
5757 for ( const I of G ? grouper ( facet , i => G [ i ] ) . values ( ) : [ facet ] ) {
58+ if ( normalize === "z" ) n = I . length ;
5859 for ( const [ x , f ] of sort ( grouper ( I , i => X [ i ] ) , first ) ) {
5960 if ( ! defined ( x ) ) continue ;
6061 const l = f . length ;
@@ -81,7 +82,7 @@ function group2(xv, yv, {z, fill, stroke, domain, normalize, ...options} = {}) {
8182 let { value : x , domain : xdomain } = { domain, ...maybeValue ( xv ) } ;
8283 let { value : y , domain : ydomain } = { domain, ...maybeValue ( yv ) } ;
8384 ( [ x , y ] = maybeTuple ( x , y ) ) ;
84- const k = normalize === true ? 100 : + normalize ;
85+ const k = normalize === true || normalize === "z" ? 100 : + normalize ;
8586 const [ X , setX ] = lazyChannel ( x ) ;
8687 const [ Y , setY ] = lazyChannel ( y ) ;
8788 const [ L , setL ] = lazyChannel ( `Frequency${ k === 100 ? " (%)" : "" } ` ) ;
@@ -113,11 +114,12 @@ function group2(xv, yv, {z, fill, stroke, domain, normalize, ...options} = {}) {
113114 const BZ = Z && setZ ( [ ] ) ;
114115 const BF = F && setF ( [ ] ) ;
115116 const BS = S && setS ( [ ] ) ;
116- const n = data . length ;
117+ let n = data . length ;
117118 let i = 0 ;
118119 for ( const facet of facets ) {
119120 const groupFacet = [ ] ;
120121 for ( const I of G ? grouper ( facet , i => G [ i ] ) . values ( ) : [ facet ] ) {
122+ if ( normalize === "z" ) n = I . length ;
121123 for ( const [ y , fy ] of sort ( grouper ( I , i => Y [ i ] ) , first ) ) {
122124 if ( ! ydefined ( y ) ) continue ;
123125 for ( const [ x , f ] of sort ( grouper ( fy , i => X [ i ] ) , first ) ) {
0 commit comments