Skip to content

Commit

Permalink
fix(react-components): fixing TCs on data zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
mnischay committed Sep 11, 2023
1 parent ddfc9c8 commit 379525c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export const useChartSetOptionSettings = (datastreams: DataStream[]) => {
*/
const settings = datastreamsDepsRef.current !== datastreamsDeps ? { replaceMerge: ['series'] } : undefined;
datastreamsDepsRef.current = datastreamsDeps;
return settings;
return { ...settings, lazyUpdate: true };
}, [datastreams]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ export const useDataZoom = (chartRef: MutableRefObject<EChartsType | null>, view
const chart = chartRef.current;
if (chart && (!isScrolling || lastUpdatedBy === 'date-picker')) {
setIsScroling(false);
chart.setOption(
{
dataZoom: { ...DEFAULT_DATA_ZOOM, startValue: viewportInMs.initial, end: 100 },
},
{ lazyUpdate: true }
);
chart.setOption({
dataZoom: { ...DEFAULT_DATA_ZOOM, startValue: viewportInMs.initial, end: 100 },
});
}
}, [chartRef, viewportInMs, isScrolling]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ const useTrendCursorsEvents = ({
// this is the ondrag handler of the trend cursor
chartRef.current?.getZr().on('drag', (event) => {
if (event.target.id.toString().startsWith('line')) {
// update user feedback
event.stop();
chartRef.current?.getZr().setCursorStyle('grab');

const graphicIndex = graphicRef.current.findIndex((g) => g.children[0].id === event.target.id);
const timeInMs = calculateTimeStamp(event.offsetX ?? 0, chartRef);
if (isInSyncModeRef.current) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const handleViewport = ({
series,
chartRef,
visualization,
size,
}: handleViewportProps) => {
const xAxisViewportInMsMinRef = useRef(viewportInMs.initial);
const xAxisViewportInMsMaxRef = useRef(viewportInMs.end);
Expand All @@ -34,10 +35,11 @@ export const handleViewport = ({

const x = calculateXFromTimestamp(g.timestampInMs, chartRef);

if (x < DEFAULT_MARGIN) {
// hiding the TC
if (x < DEFAULT_MARGIN || x > size.width - DEFAULT_MARGIN) {
// hiding the TC when it's beyond the viewport
g.ignore = true;
} else {
g.ignore = false;
// update the markers because the y value may scale as the input value changes
if (viewportInMs.isDurationViewport) {
const { trendCursorsSeriesMakersValue, trendCursorsSeriesMakersInPixels } = calculateTrendCursorsSeriesMakers(
Expand Down

0 comments on commit 379525c

Please sign in to comment.