@@ -46,7 +46,9 @@ axisContainer.node().style.pointerEvents = 'none';
4646canvasWrapper . style . right = `${ yAxisPadding } px` ;
4747canvasWrapper . style . bottom = `${ xAxisPadding } px` ;
4848
49- let { width, height } = canvas . getBoundingClientRect ( ) ;
49+ let { width, height } = canvasWrapper . getBoundingClientRect ( ) ;
50+
51+ console . log ( width , height ) ;
5052
5153xAxisContainer . attr ( 'transform' , `translate(0, ${ height } )` ) . call ( xAxis ) ;
5254yAxisContainer . attr ( 'transform' , `translate(${ width } , 0)` ) . call ( yAxis ) ;
@@ -96,11 +98,17 @@ scatterplot.subscribe('view', (event) => {
9698 yAxisContainer . call ( yAxis . scale ( event . yScale ) ) ;
9799} ) ;
98100
99- xAxisContainer . call ( xAxis . scale ( scatterplot . get ( 'xScale' ) ) ) ;
100- yAxisContainer . call ( yAxis . scale ( scatterplot . get ( 'yScale' ) ) ) ;
101+ scatterplot . subscribe (
102+ 'init' ,
103+ ( ) => {
104+ xAxisContainer . call ( xAxis . scale ( scatterplot . get ( 'xScale' ) ) ) ;
105+ yAxisContainer . call ( yAxis . scale ( scatterplot . get ( 'yScale' ) ) ) ;
106+ } ,
107+ 1
108+ ) ;
101109
102110const resizeHandler = ( ) => {
103- ( { width, height } = canvas . getBoundingClientRect ( ) ) ;
111+ ( { width, height } = canvasWrapper . getBoundingClientRect ( ) ) ;
104112
105113 xAxisContainer . attr ( 'transform' , `translate(0, ${ height } )` ) . call ( xAxis ) ;
106114 yAxisContainer . attr ( 'transform' , `translate(${ width } , 0)` ) . call ( yAxis ) ;
0 commit comments