JIT - Saving Spacetree as an Image

I am using the JavaScript InfoVis Toolkit (http://thejit.org/) and trying to save the Spacetree that I output to the image. Spacetree is displayed on the canvas. This problem really upsets me. I tried:

  • Opening canvas in a new window
  • Opening a div where the canvas is in a new window
  • Using Canvas2Image (http://www.nihilogic.dk/labs/canvas2image/)

Here is my current Javascript method (bound to a button):

function saveImage(div_id) { var canvas = document.getElementById("tree-canvas"); Canvas2Image.saveAsJPEG(canvas); } 

However, every time (and I mean this for all 3 options) I get my nodes, but NOT the label assigned by node. This does not disappoint !!

ANY VIOLATION? This should be a problem that has been launched before.

+2
source share
1 answer

For those facing this in the future, I went around this:

Change label type to "Native":

  Label: { type: 'Native', color: '#000000' }, 

And I also grabbed the canvas id (HTML 5 by the way) and dropped the image into a new window:

  function saveImage() { var canvas = document.getElementById("canvas"); window.open(canvas.toDataURL("image/jpeg")); } 
+4
source

Source: https://habr.com/ru/post/1443246/


All Articles