【问题标题】:Highlight Highcharts Organization Chart nodes突出显示 Highcharts 组织结构图节点
【发布时间】:2021-11-05 05:48:50
【问题描述】:
【问题讨论】:
标签:
highcharts
highlight
organization
【解决方案1】:
您可以通过与实现折叠类似的方式使颜色更亮。示例:
const operateChildren = (point, operation) => {
point.linksFrom.forEach(link => {
operation([
link.toNode.graphic,
link.graphic,
link.toNode.dataLabel
]);
operateChildren(link.toNode, operation);
});
};
const hideElements = (elements) => {
elements.forEach(element => {
element.hide();
});
}
const showElements = (elements) => {
elements.forEach(element => {
element.show();
});
}
const highlighElements = (elements) => {
const color = elements[0].attr('fill');
elements[0].attr({
fill: Highcharts.Color(color).brighten(0.3).get()
});
};
Highcharts.chart('container', {
plotOptions: {
series: {
point: {
events: {
click: function() {
if (this.linksFrom && this.linksFrom[0]) {
if (this.linksFrom[0].graphic.visibility === "hidden") {
operateChildren(this, showElements);
} else {
operateChildren(this, hideElements);
}
}
},
mouseOver: function() {
if (this.linksFrom) {
highlighElements([this.graphic]);
operateChildren(this, highlighElements);
}
}
}
},
...
}
},
...
});
现场演示: http://jsfiddle.net/BlackLabel/s70ujvwy/
API 参考: https://api.highcharts.com/class-reference/Highcharts.Color