Treegraph chart
author(s): Pawel Lysy
by Black Label
HTML
<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/treegraph.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<div id="container"></div>
JavaScript
(function(H) {
const {
merge,
pick
} = H;
const prototype = H._modules["Series/Treegraph/TreegraphPoint.js"].prototype.renderCollapseButton = function() {
const point = this,
series = point.series,
parentGroup = point.graphic && point.graphic.parentGroup,
levelOptions = series.mapOptionsToLevel[point.node.level || 0] || {},
btnOptions = merge(series.options.collapseButton, levelOptions.collapseButton, point.options.collapseButton),
{
width,
height,
shape,
style
} = btnOptions,
padding = 2,
chart = this.series.chart;
if (!point.shapeArgs) {
return;
}
this.collapseButtonOptions = btnOptions;
if (!point.collapseButton) {
if (!point.node.children.length || !btnOptions.enabled) {
return;
}
if (!point.visible) {
return;
}
const {
x,
y
} = this.getCollapseBtnPosition(btnOptions), fill = (btnOptions.fillColor ||
point.color ||
"#cccccc" /* Palette.neutralColor20 */ );
point.collapseButton = chart.renderer
.label(point.collapsed ? '+' : '-', x, y, shape)
.attr({
height: height - 2 * padding,
width: width - 2 * padding,
padding: padding,
fill,
rotation: chart.inverted ? 90 : 0,
rotationOriginX: width / 2,
rotationOriginY: height / 2,
stroke: btnOptions.lineColor || "#ffffff" /* Palette.backgroundColor */ ,
'stroke-width': btnOptions.lineWidth,
'text-align': 'center',
align: 'center',
zIndex: 1
})
.addClass('highcharts-tracker')
.addClass('highcharts-collapse-button')
.removeClass('highcharts-no-tooltip')
.css(merge({
color: typeof fill === 'string' ?
chart.renderer.getContrast(fill) : "#333333" /* Palette.neutralColor80 */
}, style))
.add(parentGroup);
...