/
chart_types.ts
69 lines (65 loc) · 1.34 KB
/
chart_types.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { Chart } from '../../src/types.js';
const chart = new Chart('chart', {
type: 'bar',
data: {
labels: ['1', '2', '3'],
datasets: [{
data: [1, 2, 3]
},
{
data: [1, 2, 3],
categoryPercentage: 10
}],
}
});
const chart2 = new Chart('chart', {
type: 'bar',
data: {
labels: ['1', '2', '3'],
datasets: [{
type: 'line',
data: [1, 2, 3],
// @ts-expect-error should not allow bar properties to be defined in a line dataset
categoryPercentage: 10
},
{
type: 'line',
pointBackgroundColor: 'red',
data: [1, 2, 3]
},
{
data: [1, 2, 3],
categoryPercentage: 10
}],
}
});
const chart3 = new Chart('chart', {
data: {
labels: ['1', '2', '3'],
datasets: [{
type: 'bar',
data: [1, 2, 3],
categoryPercentage: 10
},
{
type: 'bar',
data: [1, 2, 3],
// @ts-expect-error should not allow line properties to be defined in a bar dataset
pointBackgroundColor: 'red',
}],
}
});
// @ts-expect-error all datasets should have a type property or a default fallback type should be set
const chart4 = new Chart('chart', {
data: {
labels: ['1', '2', '3'],
datasets: [{
type: 'bar',
data: [1, 2, 3],
categoryPercentage: 10
},
{
data: [1, 2, 3]
}],
}
});