Highcharts fill area point interval issue

爱⌒轻易说出口 提交于 2019-12-13 03:34:49

问题


When I just draw the graph with 'spline', the yaxis interval is resaonable so the graph look's good. 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.

 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.


回答1:


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




回答2:


Simply set softThreshold property to true.

API Reference:
https://api.highcharts.com/highcharts/plotOptions.area.softThreshold

Example:
http://jsfiddle.net/srx8py4v/



来源:https://stackoverflow.com/questions/46819525/highcharts-fill-area-point-interval-issue

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