From 739d1e0fe91b90a522b4278c5ec5890cb69167b8 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 16 Mar 2017 20:43:02 +0900 Subject: [PATCH] Fix radar chart position not center Radar chart position is not center horizontally with v2.5.0. Right and left of `furthestLimits` would be switched wrongly on this refactoring commit. https://github.com/chartjs/Chart.js/pull/3625/commits/e1606f88ed4805815038cba4fdcd6211d7490356 --- src/scales/scale.radialLinear.js | 4 ++-- test/specs/scale.radialLinear.tests.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 5aa0c72c517..d61044effcd 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -144,8 +144,8 @@ module.exports = function(Chart) { // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2); var furthestLimits = { - l: scale.width, - r: 0, + r: scale.width, + l: 0, t: scale.height, b: 0 }; diff --git a/test/specs/scale.radialLinear.tests.js b/test/specs/scale.radialLinear.tests.js index baff12eb892..7796e124418 100644 --- a/test/specs/scale.radialLinear.tests.js +++ b/test/specs/scale.radialLinear.tests.js @@ -344,7 +344,7 @@ describe('Test the radial linear scale', function() { }); expect(chart.scale.drawingArea).toBe(233); - expect(chart.scale.xCenter).toBe(247); + expect(chart.scale.xCenter).toBe(256); expect(chart.scale.yCenter).toBe(280); }); @@ -393,7 +393,7 @@ describe('Test the radial linear scale', function() { expect(chart.scale.getDistanceFromCenterForValue(chart.scale.min)).toBe(0); expect(chart.scale.getDistanceFromCenterForValue(chart.scale.max)).toBe(233); expect(chart.scale.getPointPositionForValue(1, 5)).toEqual({ - x: 261, + x: 270, y: 275, });