Skip to content

Commit

Permalink
Fixed #6359, softMin/softMax didn't work in combination with floor/ce…
Browse files Browse the repository at this point in the history
…iling.
  • Loading branch information
TorsteinHonsi committed Mar 15, 2017
1 parent 2899b8a commit fe80616
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/parts/Axis.js
Expand Up @@ -1168,17 +1168,20 @@ H.Axis.prototype = {
}
}

// Handle options for floor, ceiling, softMin and softMax
// Handle options for floor, ceiling, softMin and softMax (#6359)
if (isNumber(options.softMin)) {
axis.min = Math.min(axis.min, options.softMin);
}
if (isNumber(options.softMax)) {
axis.max = Math.max(axis.max, options.softMax);
}
if (isNumber(options.floor)) {
axis.min = Math.max(axis.min, options.floor);
} else if (isNumber(options.softMin)) {
axis.min = Math.min(axis.min, options.softMin);
}
if (isNumber(options.ceiling)) {
axis.max = Math.min(axis.max, options.ceiling);
} else if (isNumber(options.softMax)) {
axis.max = Math.max(axis.max, options.softMax);
}


// When the threshold is soft, adjust the extreme value only if
// the data extreme and the padded extreme land on either side of the threshold. For example,
Expand Down
41 changes: 41 additions & 0 deletions samples/unit-tests/axis/softmin-softmax/demo.js
Expand Up @@ -61,3 +61,44 @@ QUnit.test('softMin and softMax', function (assert) {
);

});

QUnit.test('softMax combined with ceiling (#6359)', function (assert) {
var chart = Highcharts.chart('container', {
chart: {
animation: false
},
yAxis: {
softMax: 30,
ceiling: 40
},
series: [{
data: [6, 9, 2, 6, 9, 1, 2, 2, 4, 5],
animation: false
}]
});

assert.strictEqual(
chart.yAxis[0].max,
30,
'softMax takes effect'
);

chart.series[0].points[0].update(50, true, false);


assert.strictEqual(
chart.yAxis[0].max,
40,
'ceiling takes effect'
);

chart.yAxis[0].update({
ceiling: 20 // lower than softMax
});
assert.strictEqual(
chart.yAxis[0].max,
20,
'Conflicting settings, ceiling takes precedence'
);

});

0 comments on commit fe80616

Please sign in to comment.