Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(svg): svg shadow to solve apache/echarts#12614 #822

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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