-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart-hom-mark.ts
50 lines (42 loc) · 931 Bytes
/
chart-hom-mark.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
import { Chart } from '../../../src';
function HOMMark(options) {
const { encode, ...res } = options;
return [
{
type: 'interval',
...res,
encode: {
...encode,
color: 'genre',
},
},
{
type: 'line',
...options,
},
{
type: 'point',
...options,
},
];
}
export function chartHOMMark(context) {
const { container, canvas } = context;
const chart = new Chart({ container, canvas });
chart.data([
{ genre: 'Sports', sold: 275 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
]);
chart.mark(HOMMark).encode('x', 'genre').encode('y', 'sold');
chart
.text()
.style('text', 'TEST')
.style('x', '50%')
.style('y', '50%')
.style('fontSize', 40);
const finished = chart.render();
return { finished };
}