stef stef - 2 months ago 24
Javascript Question

Highcharts yAxis max not working

Anyone know why the yAxis still goes up to 15 despite the max value being set to 14? I tried playing around with

startOnTick
and
maxPadding
and didn't get very far.

http://jsfiddle.net/sag8W/

$(function () {
$('#container').highcharts({
chart: {
type: 'line'
},
yAxis: {
min: 0,
max: 14
},
startOnTick: true,
maxPadding: 0.02,
series: [
{name: "2013/10/10",
data: [5.0, 3.0, 2.5, 3.0, 3.0, 5.0]},
{name: "2014/01/10",
data: [4.0, 1.5, 2.0, 2.0, 2.0, 4.0]}
]
});
});

Answer

You need to set the tickInterval. For some funky reason it is trying to divide the 15 points you have evenly into ticks (0 to 14 is 15 points) and it doesn't want to end on an odd value of ticks so it rounds up. This is all supposition. Anyway, try this:

    yAxis: {
        min: 0, 
        max: 14,
        tickInterval: 2
    },