Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

highcharts - removing decimal places on Y axis with only one point

I have a temperature charting app that reads it's data from a JSON. When there is only 1 data point on a particular Y axis, the Y axis values are showing all the decimal places of the point, even though I explicitly asked for no decimal places. Any ideas, or is this a bug?

Fiddle: http://jsfiddle.net/e10u6sx1/

$(function () {
    $('#container').highcharts({
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
        yAxis: [{
            tickInterval: 1,
            allowDecimals: false,
            startOnTick: true,
            endOnTick: true
        }, {opposite: true
           }],
        series: [{
            data: [2.933] // when a second point is added, everything's fine!
        }, {
                 yAxis: 1,
            data: [1, 2, 3, 4]}
                ]
    });
});
like image 932
Joe Orost Avatar asked Sep 29 '22 17:09

Joe Orost


1 Answers

Simply set minRange for axis, like this: http://jsfiddle.net/e10u6sx1/1/

like image 117
Paweł Fus Avatar answered Oct 07 '22 21:10

Paweł Fus