-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tooltip): rerender correctly (#4962)
- Loading branch information
Showing
6 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
__tests__/integration/snapshots/tooltip/alphabet-interval-tooltip-render-update/step0.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div | ||
xmlns="http://www.w3.org/1999/xhtml" | ||
class="tooltip" | ||
style="pointer-events: none; position: absolute; visibility: visible; z-index: 8; transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1); background-color: rgba(255, 255, 255, 0.96); box-shadow: 0 6px 12px 0 rgba(0, 0, 0, 0.12); border-radius: 4px; color: rgba(0, 0, 0, 0.65); font-size: 12px; line-height: 20px; padding: 12px; min-width: 120px; max-width: 360px; font-family: Roboto-Regular; left: 10px; top: 10px;" | ||
> | ||
<div> | ||
<h2>A</h2> | ||
<span>frequency: 0.08167</span> | ||
</div> | ||
</div>; |
10 changes: 10 additions & 0 deletions
10
__tests__/integration/snapshots/tooltip/alphabet-interval-tooltip-render-update/step1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div | ||
xmlns="http://www.w3.org/1999/xhtml" | ||
class="tooltip" | ||
style="pointer-events: none; position: absolute; visibility: visible; z-index: 8; transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1); background-color: rgba(255, 255, 255, 0.96); box-shadow: 0 6px 12px 0 rgba(0, 0, 0, 0.12); border-radius: 4px; color: rgba(0, 0, 0, 0.65); font-size: 12px; line-height: 20px; padding: 12px; min-width: 120px; max-width: 360px; font-family: Roboto-Regular; left: 10px; top: 10px;" | ||
> | ||
<div> | ||
<h2>B</h2> | ||
<span>frequency: 0.01492</span> | ||
</div> | ||
</div>; |
53 changes: 53 additions & 0 deletions
53
__tests__/plots/tooltip/alphabet-interval-tooltip-render-update.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CustomEvent } from '@antv/g'; | ||
import { G2Spec, ELEMENT_CLASS_NAME } from '../../../src'; | ||
import { LEGEND_ITEMS_CLASS_NAME } from '../../../src/interaction/legendFilter'; | ||
|
||
export function alphabetIntervalTooltipRenderUpdate(): G2Spec { | ||
return { | ||
type: 'interval', | ||
paddingLeft: 60, | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
transform: [{ type: 'slice', start: 0, end: 3 }], | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'letter', | ||
}, | ||
interaction: { | ||
legendFilter: true, | ||
tooltip: { | ||
render: (_, { title, items }) => | ||
`<div><h2>${title}</h2>${items.map( | ||
(d) => `<span>${d.name}: ${d.value}</span>`, | ||
)}</di>`, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
alphabetIntervalTooltipRenderUpdate.steps = ({ canvas }) => { | ||
const { document } = canvas; | ||
return [ | ||
{ | ||
changeState: async () => { | ||
const items = document.getElementsByClassName(LEGEND_ITEMS_CLASS_NAME); | ||
const [i0] = items; | ||
i0.dispatchEvent(new CustomEvent('click')); | ||
|
||
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME); | ||
const [e0] = elements; | ||
e0.dispatchEvent(new CustomEvent('pointerover')); | ||
}, | ||
}, | ||
{ | ||
changeState: async () => { | ||
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME); | ||
const [e0] = elements; | ||
e0.dispatchEvent(new CustomEvent('pointerover')); | ||
}, | ||
}, | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters