Highcharts-yAxis tickInterval到最大数据 [英] Highcharts - yAxis tickInterval to max data

查看:621
本文介绍了Highcharts-yAxis tickInterval到最大数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试动态设置最大数量的最大值.我不确定,我在哪里做错了...

I am trying to set max value dynamically of the largest number. I am not sure, where I am doing wrong...

请帮忙吗?

在线演示

Online Demo

预期:

我得到的是

PS :我想找到最大值(例如:在本示例中为100),并显示第一个yAxisLabel和下一个值应为负(-)20,等等...

PS: I want to find max value (Eg: 100 in this example) and show that as first yAxisLabel and next values should be minus (-) 20 etc...

图表1的值[39, 35, 19, 38, 39, 48, 56, 57]

图表2值[39, 35, 19, 38, 39, 48, 56, 57]

尝试没有运气的选项:

yAxis: {
  min: 0, 
  max: 100,
  tickInterval: 20,
},

yAxis: {
  tickInterval: 20,
  tickPositioner: function(min,max){
      var act = min,
          ticks = [];
      console.log(this);
      while(act <= max){
        ticks.push(act);
        act+= this.tickInterval;
      }
      return ticks;  
  },
  min: 0,
  max: 100,
},

感谢 @Kacper Madej ,他提供了以下代码,

Thanks to @Kacper Madej who has given below code which resulted

推荐答案

可以使用tockPositioner并在其中设置刻度线:

It is possible to use tockPositioner and set ticks there like:

    showLastLabel: false,
    tickPositioner: function(min, max) {
      var ticks = [],
        tick = min,
        step = Math.round((max - min) / 7);

      while (tick < max - step / 2) {
        ticks.push(Math.round(tick));
        tick += step;
      }
      ticks.push(Math.round(max));
      ticks.push(Math.round(max+step)); //hidden - added for top padding

      return ticks;
    }

示例: http://jsfiddle.net/e6har510/

这篇关于Highcharts-yAxis tickInterval到最大数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆