简体   繁体   中英

Highcharts minimum value for area charts y-axis

I have 2 charts that use identical data, one line and one area.

If the data only has positive values, the area chart shows '0' as the minimum value

面积图

However, the line chart y axis starts with a negative value instead of 0, even though the data contains no negative values

折线图

Question: How can I have the line chart y-axis start at 0 but still maintain the ability to show negative values when the data has such values? (I tried using a combination of setting min + setExtremes after the chart is rendered, but the values are sometimes incorrect, but I would assume the solution is much simpler since the area chart can do this automatically).

There is no setting that will do this, currently.

There is a feature request to achieve this that has languished for some time, here:

Right now, you have to check your data, and if there are no negative values, set the min to 0, if there are negative values, do nothing.

It works by default for the area chart, because the area type has an explicit min value of 0 by default, and ignores that min if there are negative values

I suppose another workaround would be to use an area series, but set the fillOpacity to 0 - thereby displaying only a line, but using the area's axis scaling settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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