简体   繁体   English

HighCharts图表中不具有对数轴的最小和最大轴值

[英]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) 我有一个堆叠的柱形图,它具有对数比例的y轴( 此处是 JSFiddle,根据基本演示图改编而成)

$(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. 我研究了此Stackoverflow 上建议的所有选项,以设置确切的最小和最大y轴值,但没有成功。 What can I do to force the y-axis chart to start and end at the values I want? 如何强制y轴图以所需的值开始和结束?

As in the question you found, use Sebastian's answer, with tickPositioner . 就像您发现的问题一样,将Sebastian的答案与tickPositioner一起tickPositioner In fact, extremes are proper when setting startOnTick and endOnTick to false, just labels are not rendered. 实际上,将startOnTickendOnTick设置为false时,极端情况是正确的,只是不呈现标签。 In that case use tickPositioner , for example: 在这种情况下,请使用tickPositioner ,例如:

  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/ 和现场演示: http : //jsfiddle.net/99w72efv/5/

There is no property endOfTick -> you're looking for endOnTick 没有属性endOfTick >您在寻找endOnTick

Example: 例:

Reference: 参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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