Closed ghost closed 1 year ago
The stack trace shows that the error happens with VerticalAxis
, so it seems that we should use the y
position instead of x
.
It seems to be always the axis for which the min and max value is the same, and disappear if there is max
and min
in the Axis props. From what I see here at least.
This line could be adding too many Ticks.
The problem seems to disappear with:
in primary ticks
if(i>0 && primaryTicks[i-1].position === tick.position) return null
and in secondary ticks:
if(i>0 && tick.position === secondaryTicks[i-1].position) return null
I've tried the example you posted above and there's only one tick:
It seems that the warning happens if the data is modified while the live server is running (if it is started from scratch with it, there is no error. Maybe you can test that.)
The same thing seems to happen if a click button is allowed to change the data:
And the source.
OK I see, thank you for the reproducible example. The bug is in https://github.com/zakodium-oss/react-d3-utils/blob/6bdf5d6c3983973352bc4a27c72332398cbda5f6/src/hooks/useLinearPrimaryTicks.ts#L27-L39 (we apply the new scale to old ticks from the state). Working on a fix...
Oh, I see. It makes more sense now. You are welcome.
Edit: this is just a warning in the console but may be possible to fix?
Example
There should not be x:0 repeated but this would be common when having multiple possible axis combinations:
Error seems to come from this line. where the
getPositions
takes anx
value to make the ticks (it seems so.)Console Log This is the text error from the console: