我正在研究 this demo .为什么绘图选项颜色没有从颜色选项(两种颜色)中获取条形颜色?如您所见,两种颜色都只取一种颜色。
$(function () {
chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'bar'
},
plotOptions: {
column: {
colorByPoint: true
},
series: {
pointWidth: 50
}
},
colors: [
'#D9844B',
'#3F4539'],
credits: {
enabled: false
},
title: {
text: 'Test',
style: {
color: '#2d2d2d',
fontWeight: 'normal',
fontSize: '11',
marginBottom: '30'
}
},
xAxis: {
categories: ['Ecology & Economics', 'Economics Only'],
},
yAxis: {
tickInterval: 50,
max: 300,
title: {
text: 'Number of ROR Facilities'
}
},
legend: {
enabled: false
},
tooltip: {
formatter: function () {
return this.x + ' <b> : ' + this.y + '</b>';
}
},
series: [{
data: [29.9, 71.5],
dataLabels: {
enabled: true,
color: '#2d2d2d',
align: 'right',
x: -40,
y: 0,
style: {
fontSize: '12px',
fontFamily: 'Verdana, sans-serif'
}
}
}]
});
});
最佳答案
我认为文档有误。它说 colorByPoint
是一个栏/列选项,但你是对的,它不起作用。将其移至系列选项,它确实有效:
plotOptions: {
series: {
pointWidth: 50,
colorByPoint: true
}
},
已更新 fiddle .
关于javascript - 在 Highchart 条形图上设置颜色选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25587566/