0
下面是一个条形图,其中绿色条不会超过100,红色条不会低于-100。如何为HighChart图表设置最大y轴范围?
但是在图的y轴上,您可以看到-150%
。我发现this fix here,但它没有工作。 yAxis: {min: 0, max: 100}
有没有另外一种方法来实现这个目标?
这里是我加的条形图
function addSentimentSeries(name, data) {
var index = findTheIndex(name);
var color = name === 'Positive sentiment' ? '#009900' : '#FF0000';
if (index) {
chart.series[index].update({
showInLegend: false,
yAxis: 2,
type: 'column',
name: name,
color: color,
data: data,
dataGrouping: { enabled: false }
}, true);
} else {
chart.addSeries({
showInLegend: false,
yAxis: 2,
type: 'column',
name: name,
color: color,
data: data,
dataGrouping: { enabled: false }
}, true);
}
chart.hideLoading();
chart.redraw();
}
这是在“修复”我从我上面找到了答案实现的,它没有做任何事情的区域,我的条形图仍然显示-150%
vm.config.yAxis.push({
height: '30%',
top: '70%',
gridLineWidth: 0,
title: {
text: 'Sentiment',
style: { color: '#BFBFBF' }
},
yAxis: { min: 0, max: 100 },
offset: 0,
labels: {
formatter: function() {
return this.value + '%';
},
style: { color: '#BFBFBF' }
},
opposite: false
});
对于您找到的修复,您的意思是“它没有工作”是什么意思? –
@HalvorStrand只是增加了关于修复的更多细节 –
谢谢。 O型? 'min'和'max'应该直接在根中,而不是在'yAxis'属性中。 –