答案 0 :(得分:2)
你需要改变最小颜色和最大颜色
$(function () {
$('#container').highcharts({
colorAxis: {
minColor: '#00FF00',
maxColor: '#FF0000'
},
series: [{
type: "treemap",
layoutAlgorithm: 'squarified',
data: [{
name: 'Positive A',
value: 6,
colorValue: 1
}, {
name: 'Positive B',
value: 6,
colorValue: 2
}, {
name: 'Positive C',
value: 4,
colorValue: 3
}, {
name: 'Neutral',
value: 3,
colorValue: 4
}, {
name: 'Negative E',
value: 2,
colorValue: 5
}, {
name: 'Negative F',
value: 2,
colorValue: 6
}, {
name: 'Negative G',
value: 1,
colorValue: 7
}]
}],
title: {
text: 'Highcharts Treemap'
}
});
});
以下是JS Fiddle
答案 1 :(得分:0)
您可以在准备要加载到图表的数据时提及要使用的颜色,您可以添加检查并选择数据准备部分。
示例:
data: [{
name: 'A',
value: 6,
color: "red"
}, {
name: 'B',
value: 6,
color: "red"
}, {
name: 'C',
value: 4,
color:"green"
}, {
name: 'D',
value: 3,
color: "red"
}, {
name: 'E',
value: 2,
color:"green"
}, {
name: 'F',
value: 2,
color:"green"
}, {
name: 'G',
value: 1,
color:"yellow"
}]