yang-wei / rd3

react + d3
https://yang-wei.github.io/rd3/
MIT License
319 stars 83 forks source link

LineChart accessor: Cannot read property 'x' of undefined(…) #60

Closed jdelafon closed 8 years ago

jdelafon commented 8 years ago

Passing data = {lineData}, with lineData = [], throws

TypeError: Cannot read property 'x' of undefined(…)

apparently because the default accessor (d) => d.x does not find any d to act upon, so it takes undefined instead. The following accessors solve it, but it is ugly from a user perspective:

xAccessor={ (d) => d ? d.x : 0 }
yAccessor={ (d) => d ? d.y : 0 }

Edit: similar to #43, and probably all other charts.

yang-wei commented 8 years ago

hmmm or we can try skipping if no data is given

jdelafon commented 8 years ago

Definitely, because in the case when data is not empty, the condition in the accessors would be evaluated for every data point.

yang-wei commented 8 years ago

solve in latest release. Please reopen if it doesn't