From 4bf74ba49990c8a6f7ac0e49d3599351c1e94aca Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 23 Dec 2021 12:36:53 +0800 Subject: [PATCH] feat(ssr): add useViewBox opts in renderToSVGString --- src/core/echarts.ts | 9 +- test/ssr-animaiton-wave.html | 158 +++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 test/ssr-animaiton-wave.html diff --git a/src/core/echarts.ts b/src/core/echarts.ts index 31842f6a32..0b27eaed03 100644 --- a/src/core/echarts.ts +++ b/src/core/echarts.ts @@ -710,14 +710,19 @@ class ECharts extends Eventful { }); } - renderToSVGString(): string { + renderToSVGString(opts?: { + useViewBox?: boolean + }): string { + opts = opts || {}; const painter = this._zr.painter; if (__DEV__) { if (painter.type !== 'svg') { throw new Error('renderToSVGString can only be used in the svg renderer.'); } } - return painter.renderToString(); + return (painter as SVGPainter).renderToString({ + useViewBox: opts.useViewBox + }); } /** diff --git a/test/ssr-animaiton-wave.html b/test/ssr-animaiton-wave.html new file mode 100644 index 0000000000..b4774814ae --- /dev/null +++ b/test/ssr-animaiton-wave.html @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +