Is there anyway to export D3 JS graphs into LaTeX tikz graphs programmatically?
Asked Answered
M

1

9

There are many ways of exporting R graphs and R Tables quickly into LaTeX using the R tikzDevice (on the R side) and the LaTeX tikz package (On LaTeX side). Have a look at this blog article for more info.

Are there any automated method or JS library similar to the above concept but transforms a complete visualization in D3.JS to native LaTeX TiKz like graphs. I need that to include good resolution graphs into LaTeX papers and reports.

I know that there many ways and JS code that export visualization into PNG, JPEG, PDF etc... Is there any easy way to export D3.js into TikZ LaTeX?

Thanks for any suggestions.

Mcknight answered 6/1, 2018 at 12:34 Comment(4)
The link to the blog article you provided is broken.Desiccated
I'd generalized the question as to convert svg to TikZ language. At the time I faced this problem (2014) there was no such solution. Now the quick search reveals some attempts. Check this out: https://github.com/paaguti/svg2tikzDesiccated
The URL of the blog article is fixed nowMcknight
"Are there any automated method or JS library similar" - Just as a heads up, questions seeking recommendations for books, tools, software libraries, etc are, I think, considered opinion based and off topic.Lyingin
L
2

Not tested but pretty sure you could go: d3js->SVG->TikZ

  1. Export from d3 to SVG, e.g
d3.select(this)
  .attr("href", 'data:application/octet-stream;base64,' + btoa(d3.select("#graph").html()))
  .attr("download", "graph.svg") 
  1. Convert SVG to TikZ (SVG2TikZ, etc).

  2. Import TikZ into LaTeX

If this process works you could easily automate it using python.

I know that there many ways and JS code that export visualization into PNG, JPEG, PDF etc...

My thinking is that if you can't go direct - then to try and use one of the many ways as an intermediate format (in this case SVG) to get the data from one to the other.

Lyingin answered 28/8, 2020 at 18:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.