-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart-change-size-polar.ts
53 lines (44 loc) · 1.3 KB
/
chart-change-size-polar.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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({ 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 };
}