我有一个树状图,它定义了一个系列,该系列可以向下钻取到在钻取中定义的两个系列。向下钻取是有效的,但是当我单击面包屑尝试向后导航时,什么也没有发生。可能有些东西我没有正确设置,但我无法弄清楚我做错了什么。
Jsfiddle:https://jsfiddle.net/oLwpa0uf/
代码:
Highcharts.chart('container', {
chart: {
type: 'treemap'
},
series: [{
id: "client",
name: 'Client',
data: [{
drilldown: "10",
id: "10",
name: 'Client 10',
value: 1184
}, {
drilldown: "BE",
id: "BE",
name: 'Client BE',
value: 647
}]
}],
drilldown: {
series: [{
id: '10',
name: 'attribute_id',
data: [
{
id: "10||CF ",
name: "Attr CF ",
parent: "10",
value: 1184
}
]
}, {
id: 'BE',
name: 'attribute_id',
data: [
{
id: "BE||BF ",
name: "Attr BF ",
parent: "BE",
value: 647
}
]
}]
}
});
在 Highcharts 中使用树形图系列时,最好使用级别机制而不是钻取模块。
这是一个演示:https://jsfiddle.net/BlackLabel/fjr5gpza/
Highcharts.chart("container", {
series: [
{
type: "treemap",
layoutAlgorithm: "squarified",
allowDrillToNode: true,
dataLabels: {
enabled: false,
},
levelIsConstant: false,
levels: [
{
level: 1,
dataLabels: {
enabled: true,
},
borderWidth: 3,
},
],
data: [
{
id: "A",
name: "Category A",
color: "#EC2500",
},
{
id: "B",
name: "Category B",
color: "#ECE100",
},
{
id: "C",
name: "Category C",
color: "#EC9800",
},
{
name: "Subcategory A1",
parent: "A",
value: 6,
},
{
name: "Subcategory A2",
parent: "A",
value: 4,
},
{
name: "Subcategory B1",
parent: "B",
value: 4,
},
{
name: "Subcategory B2",
parent: "B",
value: 2,
},
{
name: "Subcategory C1",
parent: "C",
value: 4,
},
{
name: "Subcategory C2",
parent: "C",
value: 2,
},
],
},
],
title: {
text: "Treemap with Drilldown",
},
})
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<div id="container"></div>