statgen / locuszoom

A Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
https://statgen.github.io/locuszoom/
MIT License
154 stars 29 forks source link

[request] Export to PDF feature #135

Closed abought closed 4 years ago

abought commented 6 years ago

Summary

Goncalo has suggested an "export to PDF" feature for Locuszoom, as an option that would fit the data re-use workflow for some users.

This would be particularly useful as a demonstration for standalone sites. It could encompass a demonstration outside of the LocusZoom core codebase.

Scope

Assess available options and possible implementation.

abought commented 5 years ago

A few notes from initial exploration. The Inkscape option is not as convenient to the users, but seems to work well; worth documenting for anyone interested.

  1. LocusZoom.js does provide a "download image" option, which allows downloading as scalable-resolution SVG. This can be converted to PDF via a third party tool downloaded separately, to produce a PDF that maintains image quality: eg inkscape --file=mySVGinputFile.svg --export-area-drawing --without-gui --export-pdf=output.pdf

  2. Some front end methods exist (based on jspdf), but are limited and would require further custom code to handle the full range of LZ tracks.

  3. A third option would be backend rendering (demo). This would require sending the SVG to a server and receiving SVG output, which is not something we likely wish to maintain.

abought commented 4 years ago
Screen Shot 2019-11-18 at 4 24 28 PM

We periodically review on-hold feature requests for feasibility. Results: tried a new library, but conversion issues and poor alternatives persist. Per https://github.com/yWorks/svg2pdf.js/issues/82, the single biggest blocker seems to be underlying library issues with use of <style> global CSS rules, (as opposed to embedded style attributes at each node). (I tried embedding the CSS a la Dashboard.download but it did not help). Other tags and properties are also limited in other ways, and resolving those limits (eg inlining the styles) would require nontrivial rewrites + a rendering performance penalty.

There also seems to be some development slowdown / forking going on in the underlying library ecosystem. I'm very open to trying a new suggested alternative, but at present implementing this is not as small in scope as we might wish for.

For the time being, we will continue to recommend that users export via third party conversion tools if they want an image format other than SVG. (@avsmith )

abought commented 4 years ago

Will be addressed via "save as png" in #193.