apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.28k stars 19.61k forks source link

Add support for svg sprite symbols #9825

Open ClemMakesApps opened 5 years ago

ClemMakesApps commented 5 years ago

General Questions

Issue Type

Issue Details

ECharts currently supports symbols if you pass in a SVG path (https://ecomfe.github.io/echarts-doc/public/en/option.html#series-line.symbol). It would be nice if we could pass in a svg sprite sheet URL with a specific svg ID so that we can use a cached svg path rather than having to add more svg paths to the DOM.

Expected Behavior

Current Behavior

Online Example

Topics

Anything Else We Need to Know

Environment

100pah commented 5 years ago

Thanks @ClemMakesApps . The SVG path set to https://ecomfe.github.io/echarts-doc/public/en/option.html#series-line.symbol is not really converted to a SVG element, but is parsed to generate corresponding zrender graphic elements and then rendered in canvas or SVG. The performance issue has been considered inside this procedure.

ClemMakesApps commented 5 years ago

When I look at the generated code (for svg rendering), it looks like that symbol is repeated in the DOM multiple times (depending on how many times you want the symbol to be rendered). If we used an SVG sprite, we could cache the SVG symbol. You'd see a slight performance improvement if your chart contained a lot of symbols.

I don't think there would be much performance changes for canvas rendering though.

100pah commented 5 years ago

Thanks @ClemMakesApps . In canvas rendering, because the rendering mechanism is different, that probably not an issue. But for SVG rendering, that can be optimized.