Skip to content

Commit

Permalink
Fixed #19671, treegraph error when setting legendSymbol to lineMarker.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Januchta authored and Jakub Januchta committed Sep 7, 2023
1 parent 9360ca8 commit d14effc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
12 changes: 12 additions & 0 deletions samples/unit-tests/series-treegraph/treegraph/demo.js
Expand Up @@ -134,5 +134,17 @@ QUnit.test('Treegraph series',
1,
'CollapseButton should be visible when point is expanded (#19368).'
);

series.update({
showInLegend: true,
legendSymbol: 'lineMarker'
});

assert.ok(
chart.series[0].legendItem.symbol.element &&
chart.series[0].legendItem.line.element,
`Legend symbol and line should be rendered when
legendSymbol is set to lineMarker (#19671).`
);
}
);
5 changes: 3 additions & 2 deletions ts/Core/Legend/LegendSymbol.ts
Expand Up @@ -94,6 +94,7 @@ namespace LegendSymbol {
options = this.options,
symbolWidth = legend.symbolWidth,
symbolHeight = legend.symbolHeight,
symbol = this.symbol || 'circle',
generalRadius = symbolHeight / 2,
renderer = this.chart.renderer,
legendItemGroup = legendItem.group,
Expand Down Expand Up @@ -151,7 +152,7 @@ namespace LegendSymbol {
);

// Restrict symbol markers size
if ((this.symbol as any).indexOf('url') === 0) {
if (symbol.indexOf('url') === 0) {
markerOptions = merge(markerOptions, {
width: symbolHeight,
height: symbolHeight
Expand All @@ -161,7 +162,7 @@ namespace LegendSymbol {

legendItem.symbol = legendSymbol = renderer
.symbol(
this.symbol as any,
symbol,
(symbolWidth / 2) - radius,
verticalCenter - radius,
2 * radius,
Expand Down
47 changes: 27 additions & 20 deletions ts/Series/Treegraph/TreegraphSeries.ts
Expand Up @@ -532,40 +532,47 @@ class TreegraphSeries extends TreemapSeries {
state?: StatesOptionsKey
): SVGAttributes {
const series = this,
levelOptions =
levelOptions = point &&
(series.mapOptionsToLevel as any)[point.node.level || 0] || {},
options = point.options,
options = point && point.options,
stateOptions =
(levelOptions.states &&
(levelOptions.states as any)[state as any]) ||
{};
point.options.marker = merge(
series.options.marker,
levelOptions.marker,
point.options.marker
);

if (point) {
point.options.marker = merge(
series.options.marker,
levelOptions.marker,
point.options.marker
);
}

const linkColor = pick(
stateOptions.link && stateOptions.link.color,
options.link && options.link.color,
levelOptions.link && levelOptions.link.color,
stateOptions && stateOptions.link && stateOptions.link.color,
options && options.link && options.link.color,
levelOptions && levelOptions.link && levelOptions.link.color,
series.options.link && series.options.link.color
),
linkLineWidth = pick(
stateOptions.link && stateOptions.link.lineWidth,
options.link && options.link.lineWidth,
levelOptions.link && levelOptions.link.lineWidth,
stateOptions && stateOptions.link && stateOptions.link.lineWidth,
options && options.link && options.link.lineWidth,
levelOptions && levelOptions.link && levelOptions.link.lineWidth,
series.options.link && series.options.link.lineWidth
),
attribs = seriesProto.pointAttribs.call(series, point, state);

if (point.isLink) {
attribs.stroke = linkColor;
attribs['stroke-width'] = linkLineWidth;
delete attribs.fill;
}
if (!point.visible) {
attribs.opacity = 0;
if (point) {
if (point.isLink) {
attribs.stroke = linkColor;
attribs['stroke-width'] = linkLineWidth;
delete attribs.fill;
}
if (!point.visible) {
attribs.opacity = 0;
}
}

return attribs;
}

Expand Down

0 comments on commit d14effc

Please sign in to comment.