asciidoctor / asciidoctor-chart

A set of Asciidoctor extensions that add a chart block and block macro to AsciiDoc for including charts in your AsciiDoc document.
Other
29 stars 13 forks source link

Render Charts to SVG server side with d3 node module. #7

Open bwklein opened 8 years ago

bwklein commented 8 years ago

Please see this page for a working example. Render SVG Charts Server-side With D3.js

If this could be used to take a chart to svg file and then insert it into a document, it would be a great solution for both the HTML output and to PDF files.

mojavelinux commented 8 years ago

The key here will be to detect we're running outside of the browser process and generate an SVG instead of kicking it to the browser.

The chart extension shares a lot in common with Asciidoctor Diagram. I think we certainly should consider migrating this extension to an independent repository, named asciidoctor-chart, perhaps even sharing some code with Asciidoctor Diagram.

@pepijnve do you share that opinion or do you have another idea for where the chart extension should go?

bwklein commented 8 years ago

I tend to pass the attribute "pdf" from the cli when building a version that would require a rendered image instead of an interactive javascript based chart. This is what I would key on to determine which way to handle a chart object.

mojavelinux commented 8 years ago

If you are building the document using Asciidoctor PDF, you can check for the attribute backend-pdf, which is automatically set by that converter.

ggrossetie commented 3 years ago

Related issue: https://github.com/Mogztter/asciidoctor-chart/issues/1

The main challenge is that most charting libraries rely on JavaScript/DOM. Is there any pure Ruby charting library? I found https://github.com/topfunky/gruff but it relies on ImageMagick...

ggrossetie commented 2 years ago

Would it be acceptable to use https://github.com/rubycdp/ferrum to interact with a Chrome headless instance and generate SVG? When transpiling to JavaScript we could implement the same logic using Puppeteer (i.e., replace Ferrum by Puppeteer).

Since Ferrum claims to be a pure Ruby library, it might also works seamlessly on the JVM with JRuby.

cgoguyer commented 2 years ago

Is there any news on rendering chart inside PDF document ?

ggrossetie commented 2 years ago

Nope, I haven't found a good solution to implement this feature... using a Chrome instance seems a bit heavyweight! If you have a better idea, feel free to suggest it or even better submit a pull request.

As an alternative, you can try https://github.com/mogztter/asciidoctor-web-pdf which relies on web technologies to produce a PDF.