]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix radar chart horizontal position (#4032)
authorHiroshi Shirosaki <h.shirosaki@gmail.com>
Tue, 21 Mar 2017 00:39:18 +0000 (09:39 +0900)
committerEvert Timberg <evert.timberg+github@gmail.com>
Tue, 21 Mar 2017 00:39:18 +0000 (20:39 -0400)
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
test/specs/scale.radialLinear.tests.js

index 5aa0c72c517a098a240ccea50c24572144f4798b..d61044effcd45459190a1881d591e1be9892c2e3 100644 (file)
@@ -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
                };
index baff12eb892d67a1fb5ecfb8a7885d12744d9a6e..7796e124418fd6ed54e799780605b2e37f05354c 100644 (file)
@@ -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,
                });