mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Reversible Legends
Legends can now be reversed with the `reversed: true` property.
This commit is contained in:
parent
ac5be9bde2
commit
ee81d4a804
@ -9,6 +9,7 @@ module.exports = function(Chart) {
|
||||
display: true,
|
||||
position: 'top',
|
||||
fullWidth: true, // marks that this box should take the full width of the canvas (pushing down other boxes)
|
||||
reverse: false,
|
||||
|
||||
// a callback that will handle
|
||||
onClick: function(e, legendItem) {
|
||||
@ -143,6 +144,9 @@ module.exports = function(Chart) {
|
||||
beforeBuildLabels: helpers.noop,
|
||||
buildLabels: function() {
|
||||
this.legendItems = this.options.labels.generateLabels.call(this, this.chart.data);
|
||||
if(this.options.reverse){
|
||||
this.legendItems.reverse();
|
||||
}
|
||||
},
|
||||
afterBuildLabels: helpers.noop,
|
||||
|
||||
@ -321,4 +325,4 @@ module.exports = function(Chart) {
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@ -11,6 +11,7 @@ describe('Legend block tests', function() {
|
||||
display: true,
|
||||
position: 'top',
|
||||
fullWidth: true, // marks that this box should take the full width of the canvas (pushing down other boxes)
|
||||
reverse: false,
|
||||
|
||||
// a callback that will handle
|
||||
onClick: jasmine.any(Function),
|
||||
@ -305,4 +306,4 @@ describe('Legend block tests', function() {
|
||||
"args": ["dataset3", 228, 132]
|
||||
}]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user