Skip to content

Commit

Permalink
Tests for scriptable borderAlign option
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Jan 9, 2019
1 parent e2a0ed1 commit 6c3ea48
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/fixtures/controller.doughnut/borderAlign/indexable.js
@@ -0,0 +1,52 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderAlign: [
'center',
'inner',
'center',
'inner',
'center',
'inner',
],
borderColor: '#00ff00'
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: '#ff0000',
borderWidth: 5,
borderAlign: [
'center',
'inner',
'center',
'inner',
'center',
'inner',
]
}
},
}
},
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.
44 changes: 44 additions & 0 deletions test/fixtures/controller.doughnut/borderAlign/scriptable.js
@@ -0,0 +1,44 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderAlign: function(ctx) {
var value = ctx.dataset.data[ctx.dataIndex] || 0;
return value > 4 ? 'inner' : 'center';
},
borderColor: '#0000ff',
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderColor: '#ff00ff',
borderWidth: 8,
borderAlign: function(ctx) {
var value = ctx.dataset.data[ctx.dataIndex] || 0;
return value > 4 ? 'center' : 'inner';
}
}
},
}
},
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.
38 changes: 38 additions & 0 deletions test/fixtures/controller.doughnut/borderAlign/value.js
@@ -0,0 +1,38 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
// option in dataset
data: [0, 2, 4, null, 6, 8],
borderAlign: 'inner',
borderColor: '#00ff00',
},
{
// option in element (fallback)
data: [0, 2, 4, null, 6, 8],
}
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',
borderAlign: 'center',
borderColor: '#0000ff',
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 6c3ea48

Please sign in to comment.