问题
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