@@ -2,7 +2,7 @@ import {ascending} from "d3-array";
22import { create } from "d3-selection" ;
33import { filter } from "../defined.js" ;
44import { Mark , number , identity , indexOf , first , second , maybeColor } from "../mark.js" ;
5- import { Style , applyDirectStyles , applyIndirectStyles } from "../style.js" ;
5+ import { Style , applyDirectStyles , applyIndirectStyles , applyBandTransform } from "../style.js" ;
66
77class AbstractBar extends Mark {
88 constructor (
@@ -45,6 +45,7 @@ class AbstractBar extends Mark {
4545 if ( Z ) index . sort ( ( i , j ) => ascending ( Z [ i ] , Z [ j ] ) ) ;
4646 return create ( "svg:g" )
4747 . call ( applyIndirectStyles , this )
48+ . call ( this . _transform , scales )
4849 . call ( g => g . selectAll ( )
4950 . data ( index )
5051 . join ( "rect" )
@@ -70,6 +71,9 @@ export class Bar extends AbstractBar {
7071 options
7172 ) ;
7273 }
74+ _transform ( ) {
75+ // noop
76+ }
7377 _x ( { x} , { x : X } ) {
7478 const { insetLeft} = this ;
7579 return i => x ( X [ i ] ) + insetLeft ;
@@ -100,6 +104,9 @@ export class BarX extends AbstractBar {
100104 options
101105 ) ;
102106 }
107+ _transform ( selection , { x} ) {
108+ selection . call ( applyBandTransform , x , false ) ;
109+ }
103110 _x ( { x} , { x : X } ) {
104111 const { insetLeft} = this ;
105112 return i => Math . min ( x ( 0 ) , x ( X [ i ] ) ) + insetLeft ;
@@ -130,6 +137,9 @@ export class BarY extends AbstractBar {
130137 options
131138 ) ;
132139 }
140+ _transform ( selection , { y} ) {
141+ selection . call ( applyBandTransform , false , y ) ;
142+ }
133143 _x ( { x} , { x : X } ) {
134144 const { insetLeft} = this ;
135145 return i => x ( X [ i ] ) + insetLeft ;
0 commit comments