Skip to content

Commit

Permalink
Add initial web-renderer for rendering charts created with javascript
Browse files Browse the repository at this point in the history
Some visualization libraries like vega output html/javascript code which must be
run in order to render the visualization. Emacs will eventually be able to
handle this through xwidgets, but in the meantime it's nice to have at least an
image of the visualization in the org-mode frontend.

To accomplish this, we can introduce a web-renderer backend that uses headless
chrome or firefox in order to render the visualization, takes a screenshot, and
then crops the screenshot in order to get the final visualization as a png.

Currently, the backend is not hooked up to the org-client. It also takes a
naive approach, assuming html input and a Chrome installation on macOS. It also
creates an output file in order to demonstrate the intermediate results.

Try running `cd web-renderer && cat test_chart.html | npm start`

The image manipulation could also use some work. The image is trimmed very close
and could use some margins.
  • Loading branch information
lane-s committed Nov 6, 2019
1 parent 590b84e commit 390f115
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions js/web-renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ process.stdin.on('end', () => {

await process.stdout.write(croppedImage);
await browser.close();

require('fs').writeFileSync('image.png', croppedImage);
})();
})

0 comments on commit 390f115

Please sign in to comment.