Domanda

I'm using JavaScript InfoVis Toolkit (http://thejit.org/) and am trying to save the Spacetree that I output into an image. The Spacetree is outputted to a canvas. This problem is really frustrating me. I have tried:

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

Here is my current Javascript method (tied 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 that is assigned to the node. It's beyond frustrating!!

Has ANYONE run into this? This has to be an issue that has been run into before..

È stato utile?

Soluzione

For anyone that runs into this in the future, I got around this by:

Changing the Label type to "Native":

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

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

    function saveImage() {

        var canvas = document.getElementById("canvas");
        window.open(canvas.toDataURL("image/jpeg"));
    }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top