echarts icon indicating copy to clipboard operation
echarts copied to clipboard

SVG renderer / export

Open jarben opened this issue 11 years ago • 29 comments

It's great that ECharts uses ZRender abstraction to draw stuff into canvas. Makes me thinking how hard would it be to render it as SVG? It doesn't need to support animations, the use case is to download a snapshot of what you see into SVG so it can be potentially printed etc.

Is there any in-memory tree of shapes with calculated positions that can be rendered by something else?

jarben avatar Jul 02 '15 05:07 jarben

@jarben we are attempting to do something similar and would love SVG support, any update here?

jordansmith42 avatar Jun 22 '17 21:06 jordansmith42

@jordansmith42 We are developing a brand new SVG renderer. It will solve this issue then.

pissang avatar Jun 23 '17 02:06 pissang

This is a great news @pissang, you guys rock!

jarben avatar Jun 23 '17 10:06 jarben

That's awesome @pissang, very excited about this. Any idea of a timeline?

jordansmith42 avatar Jun 23 '17 16:06 jordansmith42

@jordansmith42 Not sure yet. It probably will take much more time than we think to do testing.

pissang avatar Jun 24 '17 14:06 pissang

We are now preparing the SVG rendering and export work and we'd like to hear @jarben @jordansmith42 if you have any application scenarios that may help us better understand this feature. When would you prefer SVG to canvas?

Ovilia avatar Aug 15 '17 02:08 Ovilia

Hi Olivia, that's great to hear, one of the most asked scenario is to be able to save graph in vector so it is possible to print it anywhere. Im on holiday now, will write more when i get back. Anyway, great news about the svg rendering!

jarben avatar Aug 15 '17 05:08 jarben

Hi, That would be great, thank you. I need the SVG feature because we convert html to PDF to create reports. SVG remain vector on the PDF, so it is much lighter in size and resolution independent.

Thanks for this great library.

Kfir

On Aug 15, 2017 5:22 AM, "Wenli Zhang" [email protected] wrote:

We are now preparing the SVG rendering and export work. @jarben https://github.com/jarben @jordansmith42 https://github.com/jordansmith42 Do you have any application scenarios that may help us better understand this feature? When would you prefer SVG to canvas?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ecomfe/echarts/issues/1764#issuecomment-322359532, or mute the thread https://github.com/notifications/unsubscribe-auth/ADcx5-rlO-JK5S6bwx5ry5QAAbx8IdEOks5sYQDXgaJpZM4FQZvk .

kfirdado avatar Aug 15 '17 05:08 kfirdado

@jarben Have a nice holiday! And when you're back, it would be very nice of you to tell me more about why using SVG for printing is better, since I believe you may also make a large enough canvas (like 2x) to make it?

Ovilia avatar Aug 15 '17 08:08 Ovilia

@kfirdado That sounds reasonable for me. 😃 Another question is, if ECharts provides an extra method to export charts as PDF file with charts in SVG format inside, would it be helpful to you in this case? Or it happens more often that you need to add some extra content in the PDF, in which case exporting charts as PDF may not be very helpful?

Ovilia avatar Aug 15 '17 08:08 Ovilia

Report is based not only on charts (tables, header, footer, text), and layout is customizable, so it would be best and most flexible to allow rendering charts as SVG in target div. Exporting as PDF would not be useful to us, but can be another nice feature to share single chart.

Kfir Dadosh

On Aug 15, 2017 11:29, "Wenli Zhang" [email protected] wrote:

@kfirdado https://github.com/kfirdado That sounds reasonable for me. 😃 Another question is, if ECharts provides an extra method to export charts as PDF file with charts in SVG format inside, would it be helpful to you in this case? Or it happens more often that you need to add some extra content in the PDF, in which case exporting charts as PDF may not be very helpful?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ecomfe/echarts/issues/1764#issuecomment-322410109, or mute the thread https://github.com/notifications/unsubscribe-auth/ADcx5_0aeyEkw5ZsKwSAS4cnalARl08Fks5sYVbYgaJpZM4FQZvk .

kfirdado avatar Aug 15 '17 16:08 kfirdado

@kfirdado Thanks! That's very helpful.

Ovilia avatar Aug 15 '17 16:08 Ovilia

Our use case is almost the same as @kfirdado, we're rendering charts into reports with other types of items which will likely be printed to PDF and likely to paper. Currently using canvas to achieve any reasonable resolution we're forced to bump DPI resulting in a very heavy file size or do what we're currently doing, use another library that sits on top of canvas and rerenders as an svg.

jordansmith42 avatar Aug 15 '17 17:08 jordansmith42

@jordansmith42 Thanks for that! 😄

Ovilia avatar Aug 16 '17 01:08 Ovilia

+1 for SVG option. Would be interested to see if there's a way to specify a custom class name to the graphics drawn. I guess that way we could style certain parts of the chart with CSS. Just today I was running the SVG tests in zrender 😍

jonavila avatar Aug 16 '17 17:08 jonavila

@psumstr Thanks for your suggestion. Although we may not provide class name for users to use CSS to change certain parts of the chart, since this may interfere with the chart rendering and cause potential problems.

Ovilia avatar Aug 17 '17 02:08 Ovilia

@Ovilia Thanks for the quick reply. Yeah, I haven't thought of the full implications of adding classes to chart elements, but AMCharts does something like this: https://www.amcharts.com/kbase/css-class-names/ https://www.amcharts.com/kbase/css-animations/

SVG rendering may also allow for future accessibility requirements (screen reader compatibility). Looking forward to all the future improvements.

jonavila avatar Aug 17 '17 03:08 jonavila

@psumstr Thanks for your advice. We will consider them when making our SVG version. 😄

Ovilia avatar Aug 17 '17 05:08 Ovilia

Hi @Ovilia , regarding the printable size, similarly to what @jordansmith42 has mentioned, vector is much smaller and suitable for PDFs. Also, SVG is easily editable which is great for using ECharts inside infographics.

Also agree with @psumstr around using CSS to customize charts. There might be some implications but's that's same as any widget library in HTML isn't it?

Anyway, thanks again for asking and working on this, it's such a good news!

jarben avatar Aug 21 '17 07:08 jarben

@jarben We will consider the CSS suggestion. Thank you!

Ovilia avatar Aug 21 '17 08:08 Ovilia