-
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(legend): update legend item (#5258)
- Loading branch information
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
__tests__/integration/api-chart-change-data-legend.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,23 @@ | ||
import { chartChangeDataLegend as render } from '../plots/api/chart-change-data-legend'; | ||
import { createNodeGCanvas } from './utils/createNodeGCanvas'; | ||
import { sleep } from './utils/sleep'; | ||
import './utils/useSnapshotMatchers'; | ||
|
||
describe('chart.changeData', () => { | ||
const canvas = createNodeGCanvas(640, 480); | ||
|
||
it('mark.changeSize(width, height) should rerender expected chart', async () => { | ||
const { finished } = render({ | ||
canvas, | ||
container: document.createElement('div'), | ||
}); | ||
await finished; | ||
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.
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,43 @@ | ||
import { Chart } from '../../../src'; | ||
|
||
export function chartChangeDataLegend(context) { | ||
const { container, canvas } = context; | ||
|
||
const chart = new Chart({ | ||
theme: 'classic', | ||
container, | ||
canvas, | ||
}); | ||
|
||
const data = [ | ||
{ time: '10:10', call: 4, waiting: 2, people: 2, type: 'a' }, | ||
{ time: '10:10', call: 2, waiting: 6, people: 3, type: 'b' }, | ||
{ time: '10:20', call: 13, waiting: 2, people: 5, type: 'a' }, | ||
{ time: '10:20', call: 9, waiting: 9, people: 1, type: 'b' }, | ||
{ time: '10:30', call: 5, waiting: 2, people: 3, type: 'a' }, | ||
{ time: '10:30', call: 8, waiting: 5, people: 1, type: 'b' }, | ||
{ time: '10:40', call: 13, waiting: 1, people: 2, type: 'a' }, | ||
{ time: '10:40', call: 13, waiting: 3, people: 2, type: 'b' }, | ||
]; | ||
|
||
chart.options({ | ||
theme: 'classic', | ||
type: 'interval', | ||
data, | ||
encode: { | ||
x: 'time', | ||
y: 'waiting', | ||
color: 'type', | ||
}, | ||
transform: [{ type: 'dodgeX' }], | ||
labels: [{ text: 'type' }], | ||
}); | ||
|
||
const finished = chart | ||
.render() | ||
.then((chart) => | ||
chart.changeData(data.sort((x, y) => (x.type > y.type ? -1 : 1))), | ||
); | ||
|
||
return { chart, finished }; | ||
} |
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