angular - 如何在树形图平方图表上自定义绘制每个图块
问题描述
我还需要显示嵌套数据。当您单击一个单元格时,会显示其他数据。
我一直在阅读文档并在谷歌中搜索,但找不到任何解决方案。这就是我现在绘制图表的方式
我正在使用“订单”字段来填充每个图块值。我接近获得最终结果,但第二个和第三个瓷砖以我需要的不同方式适合。
https://jsfiddle.net/elefantelimpio/vmt4nLp5/11/
const highChartOptions = {
colorAxis: {
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
},
drillUpButton: {
position: {
align: 'right',
x: -10,
y: 10
}
},
series: [{
type: 'treemap',
layoutAlgorithm: 'squarified',
allowDrillToNode: true,
animationLimit: 1000,
dataLabels: {
enabled: false
},
levelIsConstant: false,
levels: [{
level: 1,
dataLabels: {
enabled: true
},
borderWidth: 3
}],
turboThreshold: 100000,
data: [],
}],
tooltip: {
formatter: function () {
return this.point.realValue || this.point.value;
}
},
title: {
text: ''
}
};
data.forEach((motivator, index) => {
motivadorPoint = {
id: motivator._id,
name: motivator._id,
color: Highcharts.getOptions().colors[index],
realValue: motivator.count,
value: motivator.order
};
motivator.employees.forEach(employee => {
employeePoint = {
id: employee,
name: `${employee.name} ${employee.lastName1} ${employee.lastName2}`,
parent: motivator._id,
value: 10
};
highChartOptions.series[0].data.push(employeePoint);
});
highChartOptions.series[0].data.push(motivadorPoint);
});
Highcharts.chart('container', highChartOptions);
解决方案
您是否尝试过使用SliceAndDice布局算法?Highcharts 演示示例看起来像您的要求。
Highcharts.chart('container', {
series: [{
type: "treemap",
data: [{
name: 'A',
value: 6
}, {
name: 'B',
value: 6
}, {
name: 'C',
value: 4
}, {
name: 'D',
value: 3
}, {
name: 'E',
value: 2
}, {
name: 'F',
value: 2
}, {
name: 'G',
value: 1
}]
}],
title: {
text: 'Highcharts Treemap'
}
});
API:https ://api.highcharts.com/highcharts/series.treemap.layoutAlgorithm
编辑
经过讨论 - 这种情况下的最佳解决方案是使用与树图系列混合的钻取模块。
推荐阅读
- python - 如果匹配,如何删除这部分字符串并将其与列表进行比较?
- regex - 正则表达式匹配特定位置的字符串
- android - 如何从抽屉android中隐藏一项
- python - 使用逆波兰表示法构建具有 x,y 参数的函数
- javascript - eslint no-unused-vars varIgnorePattern 不起作用
- javascript - 如何在 d3.js 中将图例定位到圆环图?
- xamarin - 从 iOS 存储 Xamarin 表单中选择文件
- python - Beautiful Soup - HTML Parser 似乎在评论后没有拉入东西
- c# - Action.Invoke:具体写在哪里?
- html - Title 元素是否可以具有 aria-hidden 属性来隐藏页面标题