Reversible Legends

Legends can now be reversed with the `reversed: true` property.
This commit is contained in:
Tanner Linsley 2016-02-17 12:42:09 -07:00
parent ac5be9bde2
commit ee81d4a804
2 changed files with 7 additions and 2 deletions

View File

@ -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) {
}
});
};
};

View File

@ -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]
}]);
});
});
});