-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement scriptable options for doughnut charts (#5966)
- Loading branch information
1 parent
e03d8d8
commit e1ed26f
Showing
29 changed files
with
719 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/fixtures/controller.doughnut/backgroundColor/indexable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
}; |
Loading
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
46
test/fixtures/controller.doughnut/backgroundColor/scriptable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
}; |
Loading
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
34
test/fixtures/controller.doughnut/backgroundColor/value.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions
52
test/fixtures/controller.doughnut/borderAlign/indexable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
}; |
Loading
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
44
test/fixtures/controller.doughnut/borderAlign/scriptable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.