简体   繁体   中英

min and max axis value not respected in HighCharts chart with a logarithmic axis

I have the a stacked column chart with a logarithmic scaled y axis (JSFiddle here , adapted from a basic demo chart)

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        yAxis: {
                type:'logarithmic',
            min: 0.3, // I WANT THE Y-AXIS TO START AT 0.3
            min: 25, // I WANT THE Y-AXIS TO END AT 25
            endOfTick:false,
            maxPadding:0,
                    tickInterval:0.1,
        },
        plotOptions: {
            column: {
                stacking: 'normal',
            }
        },
        series: [{
            data: [5, 3, 4, 7, 2]
        }, {
            data: [2, 2, 3, 2, 1]
        }, {
            data: [3, 4, 4, 2, 5]
        }]
    });
});

I worked on all the options suggested on this Stackoverflow page to set the exact minimum and maximum y-axis values but without success. What can I do to force the y-axis chart to start and end at the values I want?

As in the question you found, use Sebastian's answer, with tickPositioner . In fact, extremes are proper when setting startOnTick and endOnTick to false, just labels are not rendered. In that case use tickPositioner , for example:

  tickPositioner: function(min, max) {
    var ticks = this.tickPositions;

    ticks = $(ticks).filter(function(i, tick) {
      return tick > min && tick < max;
    });

    ticks.slice(0, 0, min);
    ticks.push(max);

    return ticks;

  }

And live demo: http://jsfiddle.net/99w72efv/5/

There is no property endOfTick -> you're looking for endOnTick

Example:

Reference:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM