Skip to content

Commit

Permalink
fix: tooltip tips 透出 record 参数
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed Mar 26, 2024
1 parent 436ec06 commit 1ab120d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/f2/src/components/tooltip/tooltipView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const RenderXTip = (props) => {
xPositionType === 'coord'
? coordData.xText
: isFunction(xTip)
? xTip(xFirstText)
? xTip(xFirstText, firstRecord)
: xFirstText,
}}
/>
Expand Down Expand Up @@ -250,7 +250,7 @@ const RenderYTip = (props) => {
yPositionType === 'coord'
? coordData.yText
: isFunction(yTip)
? yTip(yFirstText)
? yTip(yFirstText, firstRecord)
: yFirstText,
}}
/>
Expand Down
14 changes: 14 additions & 0 deletions packages/f2/test/components/tooltip/tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ describe('tooltip', () => {
});

it('Tooltip-xTip-yTip相关配置', async () => {
const xTipFn = jest.fn();
const yTipFn = jest.fn();
const context = createContext('Tooltip xTip yTip相关配置');
const { props } = (
<Canvas context={context} pixelRatio={1} animate={false}>
Expand Down Expand Up @@ -448,6 +450,14 @@ describe('tooltip', () => {
fill: 'red',
text: '',
}}
xTip={(text, record) => {
xTipFn(text, record);
return text;
}}
yTip={(text, record) => {
yTipFn(text, record);
return text;
}}
/>
</Chart>
</Canvas>
Expand All @@ -460,6 +470,10 @@ describe('tooltip', () => {

await delay(100);
expect(context).toMatchImageSnapshot();
expect(xTipFn.mock.calls.length).toBe(1);
expect(yTipFn.mock.calls.length).toBe(1);
expect(xTipFn.mock.calls[0][1]).toBeDefined();
expect(yTipFn.mock.calls[0][1]).toBeDefined();
});

it('Tooltip 自动换行', async () => {
Expand Down

0 comments on commit 1ab120d

Please sign in to comment.