-
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(animation): shape to shape animation take style.transform into ac…
…count (#4849)
- Loading branch information
Showing
5 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
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,25 @@ | ||
import { chartChangeSizePolar as render } from '../plots/api/chart-change-size-polar'; | ||
import { createNodeGCanvas } from './utils/createNodeGCanvas'; | ||
import { sleep } from './utils/sleep'; | ||
import './utils/useSnapshotMatchers'; | ||
|
||
describe('mark.changeSize', () => { | ||
const canvas = createNodeGCanvas(640, 480); | ||
|
||
it('mark.changeSize(width, height) should rerender expected chart', async () => { | ||
const { finished, button, resized } = render({ | ||
canvas, | ||
container: document.createElement('div'), | ||
}); | ||
await finished; | ||
button.dispatchEvent(new CustomEvent('click')); | ||
await resized; | ||
const dir = `${__dirname}/snapshots/api`; | ||
await sleep(20); | ||
await expect(canvas).toMatchCanvasSnapshot(dir, render.name); | ||
}); | ||
|
||
afterAll(() => { | ||
canvas?.destroy(); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 { Chart } from '../../../src'; | ||
import { scoreByItem } from '../../data/score-by-item'; | ||
|
||
export function chartChangeSizePolar(context) { | ||
const { container, canvas } = context; | ||
|
||
const button = document.createElement('button'); | ||
button.innerText = 'Update Size'; | ||
button.style.display = 'block'; | ||
container.appendChild(button); | ||
|
||
const div = document.createElement('div'); | ||
container.appendChild(div); | ||
|
||
const chart = new Chart({ theme: 'classic', container: div, canvas }); | ||
|
||
chart.options({ | ||
type: 'view', | ||
data: scoreByItem, | ||
coordinate: { type: 'polar' }, | ||
encode: { x: 'item', y: 'score', color: 'type' }, | ||
scale: { | ||
x: { padding: 0.5, align: 0 }, | ||
y: { tickCount: 5, domainMax: 80 }, | ||
}, | ||
axis: { | ||
x: { grid: true }, | ||
y: { zIndex: 1, title: false, direction: 'center' }, | ||
}, | ||
legend: { color: { layout: { justifyContent: 'flex-start' } } }, | ||
children: [ | ||
{ | ||
type: 'area', | ||
style: { fillOpacity: 0.5 }, | ||
}, | ||
{ | ||
type: 'line', | ||
style: { lineWidth: 2 }, | ||
}, | ||
], | ||
}); | ||
|
||
const finished = chart.render(); | ||
|
||
let resolve; | ||
const resized = new Promise((r) => (resolve = r)); | ||
|
||
button.onclick = () => { | ||
chart.options({ width: 400, height: 300 }).render().then(resolve); | ||
}; | ||
|
||
return { chart, button, finished, resized }; | ||
} |
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