Skip to content

Commit

Permalink
fix(svg): svg shadow to solve apache/echarts#12614
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Sep 10, 2021
1 parent f1f0381 commit e559d72
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/svg/helper/ShadowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class ShadowManager extends Definable {
if (!shadowDom) {
shadowDom = this.createElement('filter') as SVGFilterElement;
shadowDom.setAttribute('id', 'zr' + this._zrId + '-shadow-' + this.nextId++);
shadowDom.setAttribute('filterUnits', 'userSpaceOnUse');
const domChild = this.createElement('feDropShadow');
shadowDom.appendChild(domChild);
this.addDom(shadowDom);
Expand Down
24 changes: 23 additions & 1 deletion test/svg-shadow.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<h4>Canvas</h4>
<div id="main-canvas" style="width:1000px;height:200px;"></div>
<h4>SVG</h4>
<div id="main-svg" style="width:1000px;height:200px;"></div>
<div style="position: absolute; left: 10px; top: 10px">
<div style="position: absolute; right: 10px; top: 10px">
<button onclick="toggleShadow()">Toggle Shadow</button>
</div>
<script type="text/javascript">
Expand Down Expand Up @@ -46,6 +48,26 @@
rects.push(rect);
(k ? zrSvg : zrCanvas).add(rect);
}

const line = new zrender.Line({
shape: {
x1: 60,
y1: 160,
x2: 310,
y2: 160
},
style: {
stroke: 'red',
lineWidth: 3,
shadowBlur: 10,
shadowColor: 'blue',
shadowOffsetX: 10,
shadowOffsetY: 10
}
});
line.__shadowBlur = 10;
rects.push(line);
(k ? zrSvg : zrCanvas).add(line);
}

function toggleShadow() {
Expand Down

0 comments on commit e559d72

Please sign in to comment.