From: Tom Duncalf Date: Tue, 10 May 2016 11:10:01 +0000 (+0100) Subject: Add minRotation support X-Git-Tag: v2.1.3~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2505%2Fhead;p=thirdparty%2FChart.js.git Add minRotation support --- diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 142890e1b..6993c9104 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -33,6 +33,7 @@ module.exports = function(Chart) { // label settings ticks: { beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10, @@ -190,7 +191,7 @@ module.exports = function(Chart) { var lastWidth = this.ctx.measureText(this.ticks[this.ticks.length - 1]).width; var firstRotated; - this.labelRotation = 0; + this.labelRotation = this.options.ticks.minRotation || 0; this.paddingRight = 0; this.paddingLeft = 0; diff --git a/test/core.helpers.tests.js b/test/core.helpers.tests.js index 107392844..9b452515e 100644 --- a/test/core.helpers.tests.js +++ b/test/core.helpers.tests.js @@ -231,6 +231,7 @@ describe('Core helper tests', function() { }, ticks: { beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10, @@ -262,6 +263,7 @@ describe('Core helper tests', function() { }, ticks: { beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10, diff --git a/test/scale.category.tests.js b/test/scale.category.tests.js index c26a875c2..4688f51d8 100644 --- a/test/scale.category.tests.js +++ b/test/scale.category.tests.js @@ -30,6 +30,7 @@ describe('Category scale tests', function() { }, ticks: { beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10, diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js index 8785ed2f3..afcce0af2 100644 --- a/test/scale.linear.tests.js +++ b/test/scale.linear.tests.js @@ -41,6 +41,7 @@ describe('Linear Scale', function() { }, ticks: { beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10, @@ -633,7 +634,7 @@ describe('Linear Scale', function() { } } }); - + var xScale = chartInstance.scales.xScale0; expect(xScale.getPixelForValue(1, 0, 0)).toBeCloseToPixel(501); // right - paddingRight expect(xScale.getPixelForValue(-1, 0, 0)).toBeCloseToPixel(41); // left + paddingLeft diff --git a/test/scale.logarithmic.tests.js b/test/scale.logarithmic.tests.js index 4fcfc691d..3b01fd240 100644 --- a/test/scale.logarithmic.tests.js +++ b/test/scale.logarithmic.tests.js @@ -36,6 +36,7 @@ describe('Logarithmic Scale tests', function() { }, ticks: { beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10, diff --git a/test/scale.radialLinear.tests.js b/test/scale.radialLinear.tests.js index a63c7ee78..2e0d7b672 100644 --- a/test/scale.radialLinear.tests.js +++ b/test/scale.radialLinear.tests.js @@ -54,6 +54,7 @@ describe('Test the radial linear scale', function() { backdropPaddingY: 2, backdropPaddingX: 2, beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10, diff --git a/test/scale.time.tests.js b/test/scale.time.tests.js index 5267a2b86..207a11a69 100644 --- a/test/scale.time.tests.js +++ b/test/scale.time.tests.js @@ -63,6 +63,7 @@ describe('Time scale tests', function() { }, ticks: { beginAtZero: false, + minRotation: 0, maxRotation: 50, mirror: false, padding: 10,