Skip to content

Commit bf592de

Browse files
committed
Tests for scriptable borderAlign option
1 parent f3ca6db commit bf592de

File tree

6 files changed

+134
-0
lines changed

6 files changed

+134
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = {
2+
config: {
3+
type: 'doughnut',
4+
data: {
5+
labels: [0, 1, 2, 3, 4, 5],
6+
datasets: [
7+
{
8+
// option in dataset
9+
data: [0, 2, 4, null, 6, 8],
10+
borderAlign: [
11+
'center',
12+
'inner',
13+
'center',
14+
'inner',
15+
'center',
16+
'inner',
17+
],
18+
borderColor: '#00ff00'
19+
},
20+
{
21+
// option in element (fallback)
22+
data: [0, 2, 4, null, 6, 8],
23+
}
24+
]
25+
},
26+
options: {
27+
legend: false,
28+
title: false,
29+
elements: {
30+
arc: {
31+
backgroundColor: 'transparent',
32+
borderColor: '#ff0000',
33+
borderWidth: 5,
34+
borderAlign: [
35+
'center',
36+
'inner',
37+
'center',
38+
'inner',
39+
'center',
40+
'inner',
41+
]
42+
}
43+
},
44+
}
45+
},
46+
options: {
47+
canvas: {
48+
height: 256,
49+
width: 512
50+
}
51+
}
52+
};
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
config: {
3+
type: 'doughnut',
4+
data: {
5+
labels: [0, 1, 2, 3, 4, 5],
6+
datasets: [
7+
{
8+
// option in dataset
9+
data: [0, 2, 4, null, 6, 8],
10+
borderAlign: function(ctx) {
11+
var value = ctx.dataset.data[ctx.dataIndex] || 0;
12+
return value > 4 ? 'inner' : 'center';
13+
},
14+
borderColor: '#0000ff',
15+
},
16+
{
17+
// option in element (fallback)
18+
data: [0, 2, 4, null, 6, 8],
19+
}
20+
]
21+
},
22+
options: {
23+
legend: false,
24+
title: false,
25+
elements: {
26+
arc: {
27+
backgroundColor: 'transparent',
28+
borderColor: '#ff00ff',
29+
borderWidth: 8,
30+
borderAlign: function(ctx) {
31+
var value = ctx.dataset.data[ctx.dataIndex] || 0;
32+
return value > 4 ? 'center' : 'inner';
33+
}
34+
}
35+
},
36+
}
37+
},
38+
options: {
39+
canvas: {
40+
height: 256,
41+
width: 512
42+
}
43+
}
44+
};
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
config: {
3+
type: 'doughnut',
4+
data: {
5+
labels: [0, 1, 2, 3, 4, 5],
6+
datasets: [
7+
{
8+
// option in dataset
9+
data: [0, 2, 4, null, 6, 8],
10+
borderAlign: 'inner',
11+
borderColor: '#00ff00',
12+
},
13+
{
14+
// option in element (fallback)
15+
data: [0, 2, 4, null, 6, 8],
16+
}
17+
]
18+
},
19+
options: {
20+
legend: false,
21+
title: false,
22+
elements: {
23+
arc: {
24+
backgroundColor: 'transparent',
25+
borderAlign: 'center',
26+
borderColor: '#0000ff',
27+
borderWidth: 4,
28+
}
29+
},
30+
}
31+
},
32+
options: {
33+
canvas: {
34+
height: 256,
35+
width: 512
36+
}
37+
}
38+
};
Loading

0 commit comments

Comments
 (0)