Highcharts fill area point interval issue

2019-08-25 05:43发布

When I just draw the graph with 'spline', the yaxis interval is resaonable so the graph look's good. enter image description here The code is as follows:

 chart: {
     type: 'spline'
 }

But, when I change the type to 'area', the interval is changed too. Therefore, the graph look's bad. enter image description here

 chart: {
     type: 'area'
 }

How can I fix it without setting label's 'min' and 'tickInterval'

I need this becuase if I set the label property, there would be followed bunch of works.

标签: highcharts
2条回答
2楼-- · 2019-08-25 06:16

One way you can achieve this, is by using the following function that triggers on the event load:

chart: {
  type: 'area',
  events: {
    load: function() {
      let chart = this;
      let tmpMaxMin = chart.yAxis[0].getExtremes();
      chart.yAxis[0].setExtremes(tmpMaxMin['dataMin'], tmpMaxMin['dataMax']);
    }
  }
},    

Working example: http://jsfiddle.net/ewolden/La13rjwf/

API on events.load: https://api.highcharts.com/highcharts/chart.events.load

API on getExtremes: https://api.highcharts.com/class-reference/Highcharts.Series#getExtremes

Answer based on: https://stackoverflow.com/a/35870891/8376046

查看更多
趁早两清
3楼-- · 2019-08-25 06:31
登录 后发表回答