-
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): non animation replace node
- Loading branch information
Showing
5 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
__tests__/integration/api-chart-render-update-non-animation.spec.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,26 @@ | ||
import { chartRenderUpdateNonAnimation as render } from '../plots/api/chart-render-update-non-animation'; | ||
import { createNodeGCanvas } from './utils/createNodeGCanvas'; | ||
import { kebabCase } from './utils/kebabCase'; | ||
import './utils/useCustomFetch'; | ||
import './utils/useSnapshotMatchers'; | ||
|
||
describe('chart.options.autoFit', () => { | ||
const dir = `${__dirname}/snapshots/api/${kebabCase(render.name)}`; | ||
const canvas = createNodeGCanvas(800, 500); | ||
|
||
it('chart({ autoFit: true }) should fit parent container', async () => { | ||
const { finished, chart, refreshed, button, ...rest } = render({ | ||
canvas, | ||
container: document.createElement('div'), | ||
}); | ||
await finished; | ||
|
||
button.dispatchEvent(new CustomEvent('click')); | ||
await refreshed; | ||
await expect(canvas).toMatchCanvasSnapshot(dir, 'step0'); | ||
}); | ||
|
||
afterAll(() => { | ||
canvas?.destroy(); | ||
}); | ||
}); |
Binary file added
BIN
+9.45 KB
__tests__/integration/snapshots/api/chart-render-update-non-animation/step0.png
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'; | ||
|
||
export function chartRenderUpdateNonAnimation(context) { | ||
const { container, canvas } = context; | ||
|
||
// button | ||
const button = document.createElement('button'); | ||
button.innerText = 'Rerender'; | ||
container.appendChild(button); | ||
|
||
// wrapperDiv | ||
const wrapperDiv = document.createElement('div'); | ||
container.appendChild(wrapperDiv); | ||
|
||
const chart = new Chart({ | ||
theme: 'classic', | ||
container: wrapperDiv, | ||
canvas, | ||
}); | ||
|
||
const options = { | ||
type: 'interval', | ||
data: [ | ||
{ genre: 'Sports', sold: 275 }, | ||
{ genre: 'Strategy', sold: 115 }, | ||
{ genre: 'Action', sold: 120 }, | ||
{ genre: 'Shooter', sold: 350 }, | ||
{ genre: 'Other', sold: 150 }, | ||
], | ||
encode: { | ||
x: 'genre', | ||
y: 'sold', | ||
}, | ||
animate: false, | ||
}; | ||
|
||
chart.options(options); | ||
|
||
const finished = chart.render(); | ||
|
||
let resolve; | ||
const refreshed = new Promise((r) => (resolve = r)); | ||
|
||
button.onclick = () => { | ||
chart.options({ | ||
...options, | ||
type: 'point', | ||
}); | ||
chart.render().then(resolve); | ||
}; | ||
|
||
return { chart, button, finished, refreshed }; | ||
} |
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