Skip to content

Commit 85b98ff

Browse files
committed
Add initial image based tests for doughnnut backgroundColor,
borderColor, and borderWidth.
1 parent 33f28ab commit 85b98ff

File tree

18 files changed

+389
-0
lines changed

18 files changed

+389
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
backgroundColor: [
11+
'#ff0000',
12+
'#00ff00',
13+
'#0000ff',
14+
'#ffff00',
15+
'#ff00ff',
16+
'#000000'
17+
]
18+
},
19+
{
20+
// option in element (fallback)
21+
data: [0, 2, 4, null, 6, 8],
22+
}
23+
]
24+
},
25+
options: {
26+
legend: false,
27+
title: false,
28+
elements: {
29+
arc: {
30+
backgroundColor: [
31+
'#ff88ff',
32+
'#888888',
33+
'#ff8800',
34+
'#00ff88',
35+
'#8800ff',
36+
'#ffff88'
37+
]
38+
}
39+
},
40+
}
41+
},
42+
options: {
43+
canvas: {
44+
height: 256,
45+
width: 512
46+
}
47+
}
48+
};
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
backgroundColor: function(ctx) {
11+
var value = ctx.dataset.data[ctx.dataIndex] || 0;
12+
return value > 8 ? '#ff0000'
13+
: value > 6 ? '#00ff00'
14+
: value > 2 ? '#0000ff'
15+
: '#ff00ff';
16+
}
17+
},
18+
{
19+
// option in element (fallback)
20+
data: [0, 2, 4, null, 6, 8],
21+
}
22+
]
23+
},
24+
options: {
25+
legend: false,
26+
title: false,
27+
elements: {
28+
arc: {
29+
backgroundColor: function(ctx) {
30+
var value = ctx.dataset.data[ctx.dataIndex] || 0;
31+
return value > 8 ? '#ff0000'
32+
: value > 6 ? '#00ff00'
33+
: value > 2 ? '#0000ff'
34+
: '#ff00ff';
35+
}
36+
}
37+
},
38+
}
39+
},
40+
options: {
41+
canvas: {
42+
height: 256,
43+
width: 512
44+
}
45+
}
46+
};
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
backgroundColor: '#ff0000'
11+
},
12+
{
13+
// option in element (fallback)
14+
data: [0, 2, 4, null, 6, 8],
15+
}
16+
]
17+
},
18+
options: {
19+
legend: false,
20+
title: false,
21+
elements: {
22+
arc: {
23+
backgroundColor: '#00ff00'
24+
}
25+
},
26+
}
27+
},
28+
options: {
29+
canvas: {
30+
height: 256,
31+
width: 512
32+
}
33+
}
34+
};
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
borderColor: [
11+
'#ff0000',
12+
'#00ff00',
13+
'#0000ff',
14+
'#ffff00',
15+
'#ff00ff',
16+
'#000000'
17+
]
18+
},
19+
{
20+
// option in element (fallback)
21+
data: [0, 2, 4, null, 6, 8],
22+
}
23+
]
24+
},
25+
options: {
26+
legend: false,
27+
title: false,
28+
elements: {
29+
arc: {
30+
backgroundColor: 'transparent',
31+
borderColor: [
32+
'#ff88ff',
33+
'#888888',
34+
'#ff8800',
35+
'#00ff88',
36+
'#8800ff',
37+
'#ffff88'
38+
],
39+
borderWidth: 8
40+
}
41+
},
42+
}
43+
},
44+
options: {
45+
canvas: {
46+
height: 256,
47+
width: 512
48+
}
49+
}
50+
};
Loading
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
borderColor: function(ctx) {
11+
var value = ctx.dataset.data[ctx.dataIndex] || 0;
12+
return value > 8 ? '#ff0000'
13+
: value > 6 ? '#00ff00'
14+
: value > 2 ? '#0000ff'
15+
: '#ff00ff';
16+
}
17+
},
18+
{
19+
// option in element (fallback)
20+
data: [0, 2, 4, null, 6, 8],
21+
}
22+
]
23+
},
24+
options: {
25+
legend: false,
26+
title: false,
27+
elements: {
28+
arc: {
29+
backgroundColor: 'transparent',
30+
borderColor: function(ctx) {
31+
var value = ctx.dataset.data[ctx.dataIndex] || 0;
32+
return value > 8 ? '#ff00ff'
33+
: value > 6 ? '#0000ff'
34+
: value > 2 ? '#ff0000'
35+
: '#00ff00';
36+
},
37+
borderWidth: 8
38+
}
39+
},
40+
}
41+
},
42+
options: {
43+
canvas: {
44+
height: 256,
45+
width: 512
46+
}
47+
}
48+
};
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
borderColor: '#ff0000'
11+
},
12+
{
13+
// option in element (fallback)
14+
data: [0, 2, 4, null, 6, 8],
15+
}
16+
]
17+
},
18+
options: {
19+
legend: false,
20+
title: false,
21+
elements: {
22+
arc: {
23+
backgroundColor: 'transparent',
24+
borderColor: '#00ff00',
25+
borderWidth: 8
26+
}
27+
},
28+
}
29+
},
30+
options: {
31+
canvas: {
32+
height: 256,
33+
width: 512
34+
}
35+
}
36+
};
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
borderWidth: [
11+
0,
12+
1,
13+
2,
14+
3,
15+
4,
16+
5
17+
]
18+
},
19+
{
20+
// option in element (fallback)
21+
data: [0, 2, 4, null, 6, 8],
22+
}
23+
]
24+
},
25+
options: {
26+
legend: false,
27+
title: false,
28+
elements: {
29+
arc: {
30+
backgroundColor: 'transparent',
31+
borderColor: '#888',
32+
borderWidth: [
33+
5,
34+
4,
35+
3,
36+
2,
37+
1,
38+
0
39+
]
40+
}
41+
},
42+
}
43+
},
44+
options: {
45+
canvas: {
46+
height: 256,
47+
width: 512
48+
}
49+
}
50+
};
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
borderWidth: function(ctx) {
11+
var value = ctx.dataset.data[ctx.dataIndex] || 0;
12+
return Math.abs(value);
13+
}
14+
},
15+
{
16+
// option in element (fallback)
17+
data: [0, 2, 4, null, 6, 8],
18+
}
19+
]
20+
},
21+
options: {
22+
legend: false,
23+
title: false,
24+
elements: {
25+
arc: {
26+
backgroundColor: 'transparent',
27+
borderColor: '#888',
28+
borderWidth: function(ctx) {
29+
return ctx.dataIndex * 2;
30+
}
31+
}
32+
},
33+
}
34+
},
35+
options: {
36+
canvas: {
37+
height: 256,
38+
width: 512
39+
}
40+
}
41+
};
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
borderWidth: 2
11+
},
12+
{
13+
// option in element (fallback)
14+
data: [0, 2, 4, null, 6, 8],
15+
}
16+
]
17+
},
18+
options: {
19+
legend: false,
20+
title: false,
21+
elements: {
22+
arc: {
23+
backgroundColor: 'transparent',
24+
borderColor: '#888',
25+
borderWidth: 4
26+
}
27+
},
28+
}
29+
},
30+
options: {
31+
canvas: {
32+
height: 256,
33+
width: 512
34+
}
35+
}
36+
};
Loading

0 commit comments

Comments
 (0)