Area charts in Highcharts: min and minPadding for y-axis

牧云@^-^@ 提交于 2020-01-17 06:22:26

问题


I would like some help with Area chart. If the series values are not 0.0, the minimum value of the chart always set into 0, and it's correctly on the bottom of the chart (ie) y-axis:

I try to set

{ min: 0, minPadding:0 } on the y-axis, but it doesn't work. Obviously I can't set a max value because I have a dynamic data. How can I solve this?

I have tried above cases in line charts its working properly, but not in Area charts?


回答1:


If your issue is to set a max (or min) dynamically, you can use event to set dynamically max and min:

var newMaxValue=60000000;
var newMinValue=10000000;

...

  events: {
    load: function() {
      var check = $('#container').highcharts();
        check.yAxis[0].setExtremes(newMinValue, newMaxValue);
    }

Check the example (jsfiddle):

$(function() {
var newMaxValue=60000000;
var newMinValue=10000000;
  $('#container').highcharts({

      chart: {
      type: 'area',

      events: {
        load: function() {
          var check = $('#container').highcharts();
            check.yAxis[0].setExtremes(newMinValue, newMaxValue);

        }
      }
    },


    series: [{
      "data": [{
        "y": 198975.14,

      }, {
        "y": 15031755.47,

      }, {
        "y": 21374471.88,
      }],
      "name": "Income Statement",
      "yAxis": 0
    }]
  });
});


来源:https://stackoverflow.com/questions/35870408/area-charts-in-highcharts-min-and-minpadding-for-y-axis

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