Skip to content

Commit

Permalink
fix #4167; shadow bug in multiseries chart
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Feb 12, 2024
1 parent e1a4400 commit 08347ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
23 changes: 18 additions & 5 deletions src/modules/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Filters {
filter = add
}
filter.componentTransfer({
rgb: { type: 'linear', slope: 1.5, intercept: intensity }
rgb: { type: 'linear', slope: 1.5, intercept: intensity },
})
})
el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse')
Expand All @@ -88,7 +88,7 @@ class Filters {
filter = add
}
filter.componentTransfer({
rgb: { type: 'linear', slope: intensity }
rgb: { type: 'linear', slope: intensity },
})
})
el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse')
Expand All @@ -103,13 +103,13 @@ class Filters {
}
case 'lighten': {
this.addLightenFilter(el, i, {
intensity
intensity,
})
break
}
case 'darken': {
this.addDarkenFilter(el, i, {
intensity
intensity,
})
break
}
Expand All @@ -121,8 +121,15 @@ class Filters {

// appends dropShadow to the filter object which can be chained with other filter effects
addShadow(add, i, attrs) {
const w = this.w
const { blur, top, left, color, opacity } = attrs

if (w.config.chart.dropShadow.enabledOnSeries?.length > 0) {
if (w.config.chart.dropShadow.enabledOnSeries.indexOf(i) === -1) {
return add
}
}

let shadowBlur = add
.flood(Array.isArray(color) ? color[i] : color, opacity)
.composite(add.sourceAlpha, 'in')
Expand All @@ -145,6 +152,12 @@ class Filters {
return el
}

if (w.config.chart.dropShadow.enabledOnSeries?.length > 0) {
if (w.config.chart.dropShadow.enabledOnSeries?.indexOf(i) === -1) {
return el
}
}

color = Array.isArray(color) ? color[i] : color

el.filter((add) => {
Expand Down Expand Up @@ -204,7 +217,7 @@ class Filters {
width: '200%',
height: '200%',
x: '-50%',
y: '-50%'
y: '-50%',
})
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/modules/Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,8 @@ class Graphics {
filters.getDefaultFilter(el, realIndex)
} else {
if (w.config.chart.dropShadow.enabled && drawShadow) {
if (
!w.config.chart.dropShadow.enabledOnSeries ||
(w.config.chart.dropShadow.enabledOnSeries &&
w.config.chart.dropShadow.enabledOnSeries.indexOf(realIndex) !== -1)
) {
const shadow = w.config.chart.dropShadow
filters.dropShadow(el, shadow, realIndex)
}
const shadow = w.config.chart.dropShadow
filters.dropShadow(el, shadow, realIndex)
}
}

Expand Down

0 comments on commit 08347ce

Please sign in to comment.