Skip to content

Commit

Permalink
Use proper reverse option in radial linear scale
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Jul 3, 2017
1 parent 225bfd3 commit d10ed37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/scales/scale.radialLinear.js
Expand Up @@ -244,7 +244,7 @@ module.exports = function(Chart) {
ctx.lineWidth = angleLineOpts.lineWidth;
ctx.strokeStyle = angleLineOpts.color;

var outerDistance = scale.getDistanceFromCenterForValue(opts.reverse ? scale.min : scale.max);
var outerDistance = scale.getDistanceFromCenterForValue(opts.ticks.reverse ? scale.min : scale.max);

// Point Label Font
var plFont = getPointLabelFontOptions(scale);
Expand Down Expand Up @@ -366,6 +366,7 @@ module.exports = function(Chart) {
},
convertTicksToLabels: function() {
var me = this;

Chart.LinearScaleBase.prototype.convertTicksToLabels.call(me);

// Point labels
Expand Down Expand Up @@ -433,7 +434,7 @@ module.exports = function(Chart) {

// Take into account half font size + the yPadding of the top value
var scalingFactor = me.drawingArea / (me.max - me.min);
if (me.options.reverse) {
if (me.options.ticks.reverse) {
return (me.max - value) * scalingFactor;
}
return (value - me.min) * scalingFactor;
Expand Down Expand Up @@ -480,7 +481,7 @@ module.exports = function(Chart) {

helpers.each(me.ticks, function(label, index) {
// Don't draw a centre value (if it is minimum)
if (index > 0 || opts.reverse) {
if (index > 0 || tickOpts.reverse) {
var yCenterOffset = me.getDistanceFromCenterForValue(me.ticksAsNumbers[index]);
var yHeight = me.yCenter - yCenterOffset;

Expand Down
2 changes: 1 addition & 1 deletion test/specs/scale.radialLinear.tests.js
Expand Up @@ -401,7 +401,7 @@ describe('Test the radial linear scale', function() {
y: 275,
});

chart.scale.options.reverse = true;
chart.scale.options.ticks.reverse = true;
chart.update();

expect(chart.scale.getDistanceFromCenterForValue(chart.scale.min)).toBe(233);
Expand Down

0 comments on commit d10ed37

Please sign in to comment.