From: Tanner Linsley Date: Wed, 17 Feb 2016 19:42:09 +0000 (-0700) Subject: Reversible Legends X-Git-Tag: v2.0.0~37^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee81d4a8046167ce55a8444a617cfc9e1e6b48b3;p=thirdparty%2FChart.js.git Reversible Legends Legends can now be reversed with the `reversed: true` property. --- diff --git a/src/core/core.legend.js b/src/core/core.legend.js index e42db5825..d695f2df5 100644 --- a/src/core/core.legend.js +++ b/src/core/core.legend.js @@ -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) { } }); -}; \ No newline at end of file +}; diff --git a/test/core.legend.tests.js b/test/core.legend.tests.js index fc83e63ce..1e411827a 100644 --- a/test/core.legend.tests.js +++ b/test/core.legend.tests.js @@ -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] }]); }); -}); \ No newline at end of file +});