Skip to content

Commit

Permalink
Add initial image based tests for doughnnut backgroundColor,
Browse files Browse the repository at this point in the history
borderColor, and borderWidth.
  • Loading branch information
etimberg committed Jan 9, 2019
1 parent 33f28ab commit 85b98ff
Show file tree
Hide file tree
Showing 18 changed files with 389 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/fixtures/controller.doughnut/backgroundColor/indexable.js
@@ -0,0 +1,48 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
backgroundColor: [
'#ff0000',
'#00ff00',
'#0000ff',
'#ffff00',
'#ff00ff',
'#000000'
]
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: [
'#ff88ff',
'#888888',
'#ff8800',
'#00ff88',
'#8800ff',
'#ffff88'
]
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions test/fixtures/controller.doughnut/backgroundColor/scriptable.js
@@ -0,0 +1,46 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
backgroundColor: function(ctx) {
var value = ctx.dataset.data[ctx.dataIndex] || 0;
return value > 8 ? '#ff0000'
: value > 6 ? '#00ff00'
: value > 2 ? '#0000ff'
: '#ff00ff';
}
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: function(ctx) {
var value = ctx.dataset.data[ctx.dataIndex] || 0;
return value > 8 ? '#ff0000'
: value > 6 ? '#00ff00'
: value > 2 ? '#0000ff'
: '#ff00ff';
}
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions test/fixtures/controller.doughnut/backgroundColor/value.js
@@ -0,0 +1,34 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
backgroundColor: '#ff0000'
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: '#00ff00'
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions test/fixtures/controller.doughnut/borderColor/indexable.js
@@ -0,0 +1,50 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderColor: [
'#ff0000',
'#00ff00',
'#0000ff',
'#ffff00',
'#ff00ff',
'#000000'
]
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: [
'#ff88ff',
'#888888',
'#ff8800',
'#00ff88',
'#8800ff',
'#ffff88'
],
borderWidth: 8
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions test/fixtures/controller.doughnut/borderColor/scriptable.js
@@ -0,0 +1,48 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderColor: function(ctx) {
var value = ctx.dataset.data[ctx.dataIndex] || 0;
return value > 8 ? '#ff0000'
: value > 6 ? '#00ff00'
: value > 2 ? '#0000ff'
: '#ff00ff';
}
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: function(ctx) {
var value = ctx.dataset.data[ctx.dataIndex] || 0;
return value > 8 ? '#ff00ff'
: value > 6 ? '#0000ff'
: value > 2 ? '#ff0000'
: '#00ff00';
},
borderWidth: 8
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions test/fixtures/controller.doughnut/borderColor/value.js
@@ -0,0 +1,36 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderColor: '#ff0000'
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: '#00ff00',
borderWidth: 8
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions test/fixtures/controller.doughnut/borderWidth/indexable.js
@@ -0,0 +1,50 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderWidth: [
0,
1,
2,
3,
4,
5
]
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: '#888',
borderWidth: [
5,
4,
3,
2,
1,
0
]
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions test/fixtures/controller.doughnut/borderWidth/scriptable.js
@@ -0,0 +1,41 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderWidth: function(ctx) {
var value = ctx.dataset.data[ctx.dataIndex] || 0;
return Math.abs(value);
}
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: '#888',
borderWidth: function(ctx) {
return ctx.dataIndex * 2;
}
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions test/fixtures/controller.doughnut/borderWidth/value.js
@@ -0,0 +1,36 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderWidth: 2
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: '#888',
borderWidth: 4
}
},
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 85b98ff

Please sign in to comment.