Skip to content

Commit

Permalink
fix: fix cache of crosshair
Browse files Browse the repository at this point in the history
  • Loading branch information
xile611 committed Jan 21, 2025
1 parent 5385156 commit 2a9a57c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
27 changes: 16 additions & 11 deletions packages/vchart/src/component/crosshair/utils/cartesian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ export const layoutByValue = (
sizeRange: [0, 0],
coord,
labelsTextStyle: {},
labels: Object.keys(labelsComp).reduce((res: Record<string, ICrosshairLabelInfo>, labelKey: string) => {
res[labelKey] = { visible: false, text: '', dx: 0, dy: 0 };
labels: labelsComp
? Object.keys(labelsComp).reduce((res: Record<string, ICrosshairLabelInfo>, labelKey: string) => {
res[labelKey] = { visible: false, text: '', dx: 0, dy: 0 };

return res;
}, {}),
return res;
}, {})
: null,
visible: isVisible,
axis
};
if (enableRemain) {
newCacheInfo._isCache = true;
}
newCacheInfo._isCache = useCache;
let bandSize;
let offsetSize: number = 0;

Expand Down Expand Up @@ -136,14 +136,19 @@ export const layoutByValue = (
newCacheInfo.coordRange = [region.x1, region.x2];
newCacheInfo.sizeRange = [region.y1, region.y2];
newCacheInfo.coord = coord + layoutStartPoint.x;
newCacheInfo.labels.top.y = region.y1;
newCacheInfo.labels.bottom.y = region.y2;
if (newCacheInfo.labels) {
newCacheInfo.labels.top.y = region.y1;
newCacheInfo.labels.bottom.y = region.y2;
}
} else {
newCacheInfo.coordRange = [region.y1, region.y2]; // todo
newCacheInfo.sizeRange = [region.x1, region.x2];
newCacheInfo.coord = coord + layoutStartPoint.y;
newCacheInfo.labels.left.x = region.x1;
newCacheInfo.labels.right.x = region.x2;

if (newCacheInfo.labels) {
newCacheInfo.labels.left.x = region.x1;
newCacheInfo.labels.right.x = region.x2;
}
}

if (newCacheInfo.coord < newCacheInfo.coordRange[0] || newCacheInfo.coord > newCacheInfo.coordRange[1]) {
Expand Down
4 changes: 1 addition & 3 deletions packages/vchart/src/component/crosshair/utils/polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export const layoutByValue = (
}
} as ICrosshairInfo);

if (enableRemain) {
cacheInfo._isCache = isVisible;
}
cacheInfo._isCache = useCache;

if (field === 'valueField') {
(newInfo as any).sides = (series.angleAxisHelper.getScale(0) as BandScale).domain().length;
Expand Down

0 comments on commit 2a9a57c

Please sign in to comment.