FormidableLabs / FormidableLabs/victory
VoronoiContainer does not work with Dates on a discontinuous scale
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 536
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I want to create a timeline charts with hoverable scatter points. Therefore I wrapped a scatter chart with a voronoicontainer and a discontinuous scale to fix weekend gaps (there is no trading happening on the weekends resulting in no data points). This breaks because it seems that the voronoicontainer does some internal transformations from date to timestamp and passing it to the scale.
Error: e.getDay is not a function (after debugging e is a timestamp instead of an expected Date)
**Victory version**
Which version are you using?
36.6.8
**Code Sandbox link**
Paste following code to https://formidable.com/open-source/victory/gallery/discontinuous-scale/
```
function App() {
// no weekends included
const data = [
{ x: new Date(2023, 2, 14), y: 8 },
{ x: new Date(2023, 2, 15), y: 8 },
{ x: new Date(2023, 2, 16), y: 8 },
{ x: new Date(2023, 2, 17), y: 8 },
{ x: new Date(2023, 2, 20), y: 8 },
{ x: new Date(2023, 2, 21), y: 8 },
{ x: new Date(2023, 2, 22), y: 8 },
{ x: new Date(2023, 2, 23), y: 8 },
{ x: new Date(2023, 2, 24), y: 8 },
{ x: new Date(2023, 2, 27), y: 8 },
{ x: new Date(2023, 2, 28), y: 8 },
{ x: new Date(2023, 2, 29), y: 8 },
{ x: new Date(2023, 2, 30), y: 8 },
{ x: new Date(2023, 2, 31), y: 8 },
];
const discontinuousScale = scaleDiscontinuous(
d3Scale.scaleTime()
).discontinuityProvider(discontinuitySkipWeekends());
return (
new Date(datum.x).toString()}
voronoiBlacklist={['line']}
/>
}
>
);
}
ReactDOM.render(, mountNode);
```
**To Reproduce**
Steps to reproduce the behavior:
1. Go to https://formidable.com/open-source/victory/gallery/discontinuous-scale/
2. Paste the code
3. Open the browser console
4. Hover the chart
5. See the error in the console
**Expected behavior**
The tooltip of the voronoi container is displayed and no error in the console is there.
**Screenshots**

**Desktop (please complete the following information):**
- OS: MacOS
- Browser latest chrome
**Smartphone (please complete the following information):**
- Device: Simulator iphone 12
Contributor guide
Assessment
This issue has not been assessed yet.