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

大兔子大兔子 提交于 2019-12-12 02:49:17

问题


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?


回答1:


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/




回答2:


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

Example:

  • http://jsfiddle.net/99w72efv/4/

Reference:

  • http://api.highcharts.com/highcharts#yAxis.endOnTick


来源:https://stackoverflow.com/questions/35368207/min-and-max-axis-value-not-respected-in-highcharts-chart-with-a-logarithmic-axis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!