Skip to content

Commit db68e8e

Browse files
authored
Merge pull request #97 from oslabs-beta/remove-scroll-listener
Removed scroll listener logic to resolve performance issues
2 parents b5dc78f + 0af843d commit db68e8e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/ListeningRect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useRef } from 'react';
1+
import React, { useRef } from 'react';
22
import * as d3 from 'd3';
33
import {
44
Margin,
@@ -155,7 +155,7 @@ export default function ListeningRect({
155155
}
156156
}
157157

158-
tooltipState.distanceFromTop = tooltipState.cursorY + margin.top;
158+
tooltipState.distanceFromTop = yScale(closestYValue) + margin.top;
159159
tooltipState.distanceFromRight =
160160
width - (margin.left + tooltipState.cursorX);
161161
tooltipState.distanceFromLeft = margin.left + tooltipState.cursorX;

src/components/VoronoiCell.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/restrict-plus-operands */
2-
import React, { useState, useEffect } from 'react';
2+
import React from 'react';
33
import { VoronoiProps } from '../../types';
44
import useWindowDimensions from '../hooks/useWindowDimensions';
55

@@ -14,6 +14,10 @@ export const VoronoiCell = ({
1414
margin,
1515
}: VoronoiProps): JSX.Element => {
1616
const { width } = useWindowDimensions();
17+
18+
// The code below was commented out because of the performance issues we ran
19+
// into when charts are taking in large data sets
20+
// TODO: Figure out how to performantly use scroll to improve the performance.
1721
// const [scrollPosition, setScrollPosition] = useState(0);
1822

1923
// const handleScroll = () => {
@@ -48,7 +52,7 @@ export const VoronoiCell = ({
4852
data,
4953
};
5054

51-
tooltipState.distanceFromTop = tooltipState.cursorY + margin.top;
55+
tooltipState.distanceFromTop = cellCenter.cy + margin.top;
5256
tooltipState.distanceFromRight =
5357
width - (margin.left + tooltipState.cursorX);
5458
tooltipState.distanceFromLeft = margin.left + tooltipState.cursorX;

0 commit comments

Comments
 (0)