@@ -75,7 +75,7 @@ class XYChart extends React.PureComponent {
7575 static collectScalesFromProps ( props ) {
7676 const { xScale : xScaleObject , yScale : yScaleObject , children } = props ;
7777 const { innerWidth, innerHeight } = XYChart . getDimmensions ( props ) ;
78- const { allData, dataBySeriesType } = collectDataFromChildSeries ( children ) ;
78+ const { allData, dataBySeriesType, dataByIndex , data } = collectDataFromChildSeries ( children ) ;
7979
8080 const xScale = getScaleForAccessor ( {
8181 allData,
@@ -97,7 +97,8 @@ class XYChart extends React.PureComponent {
9797 const name = componentName ( Child ) ;
9898 if ( isBarSeries ( name ) && xScale . type !== 'band' ) {
9999 const dummyBand = getScaleForAccessor ( {
100- allData : dataBySeriesType [ name ] ,
100+ // allData: dataBySeriesType[name],
101+ allData,
101102 minAccessor : xString ,
102103 maxAccessor : xString ,
103104 type : 'band' ,
@@ -116,7 +117,7 @@ class XYChart extends React.PureComponent {
116117 } ) ;
117118
118119 return {
119- allData ,
120+ dataByIndex ,
120121 xScale,
121122 yScale,
122123 } ;
@@ -134,15 +135,24 @@ class XYChart extends React.PureComponent {
134135
135136 static getStateFromProps ( props ) {
136137 const { margin, innerWidth, innerHeight } = XYChart . getDimmensions ( props ) ;
137- const { allData, xScale, yScale } = XYChart . collectScalesFromProps ( props ) ;
138+ const { xScale, yScale } = XYChart . collectScalesFromProps ( props ) ;
139+
140+ const voronoiData = React . Children . toArray ( props . children ) . reduce ( ( result , Child ) => {
141+ if ( isSeries ( componentName ( Child ) ) && ! Child . props . disableMouseEvents ) {
142+ return result . concat (
143+ Child . props . data . filter ( d => isDefined ( getX ( d ) ) && isDefined ( getY ( d ) ) ) ,
144+ ) ;
145+ }
146+ return result ;
147+ } , [ ] ) ;
138148
139149 return {
140- allData,
141150 innerHeight,
142151 innerWidth,
143152 margin,
144153 xScale,
145154 yScale,
155+ voronoiData,
146156 voronoiX : d => xScale ( getX ( d ) ) ,
147157 voronoiY : d => yScale ( getY ( d ) ) ,
148158 } ;
@@ -203,10 +213,10 @@ class XYChart extends React.PureComponent {
203213 } = this . props ;
204214
205215 const {
206- allData,
207216 innerWidth,
208217 innerHeight,
209218 margin,
219+ voronoiData,
210220 voronoiX,
211221 voronoiY,
212222 xScale,
@@ -252,14 +262,13 @@ class XYChart extends React.PureComponent {
252262 tickStyles : { ...theme [ `${ styleKey } TickStyles` ] , ...Child . props . tickStyles } ,
253263 } ) ;
254264 } else if ( isSeries ( name ) ) {
255- const { disableMouseEvents : noMouseEvents } = Child . props ;
256265 return React . cloneElement ( Child , {
257266 xScale,
258267 yScale,
259268 barWidth,
260- onClick : noMouseEvents ? null : ( Child . props . onClick || onClick ) ,
261- onMouseLeave : noMouseEvents ? null : ( Child . props . onMouseLeave || onMouseLeave ) ,
262- onMouseMove : noMouseEvents ? null : ( Child . props . onMouseMove || onMouseMove ) ,
269+ onClick : Child . props . onClick || onClick ,
270+ onMouseLeave : Child . props . onMouseLeave || onMouseLeave ,
271+ onMouseMove : Child . props . onMouseMove || onMouseMove ,
263272 } ) ;
264273 } else if ( isCrossHair ( name ) ) {
265274 CrossHairs . push ( Child ) ;
@@ -272,7 +281,7 @@ class XYChart extends React.PureComponent {
272281
273282 { useVoronoi &&
274283 < Voronoi
275- data = { allData . filter ( d => isDefined ( d . x ) && isDefined ( d . y ) ) }
284+ data = { voronoiData }
276285 x = { voronoiX }
277286 y = { voronoiY }
278287 width = { innerWidth }
0 commit comments