Skip to content

Commit

Permalink
fix: guide 超出范围不显示 (#1941)
Browse files Browse the repository at this point in the history
Co-authored-by: xuying.xu <xuying.xu@alibaba-inc.com>
  • Loading branch information
tangying1027 and xuying.xu authored Mar 20, 2024
1 parent 68bf7d6 commit 2ffcc5d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/f2/src/components/guide/withGuide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export default function<IProps extends GuideProps = GuideProps>(
const { width, height } = context;
const points = this.convertPoints(records);
const theme = this.getGuideTheme();
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y))
if(checkNaN) return;

return (
<group
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/f2/test/components/guide/guide.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ describe('Guide ', () => {
});
it('tag', () => {});

it('guide 超出范围', async() => {
const context = createContext();
const { props } = (
<Canvas context={context} pixelRatio={1} animate={false}>
<Chart data={data}>
<Line x="genre" y="sold" color="type" />
<PointGuide records={[{ genre: 'test', sold: 450, type: 'a' }]} offsetX="0px" offsetY="0px" />
</Chart>
</Canvas>
);

const chart = new Canvas(props);
chart.render();
await delay(50);
expect(context).toMatchImageSnapshot();
});
it('使用min、max、median', async () => {
const context = createContext();
const { props } = (
Expand Down

0 comments on commit 2ffcc5d

Please sign in to comment.