JIT - Saving Spacetree as an image

别来无恙 提交于 2019-12-06 10:13:14

问题


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..


回答1:


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"));
    }


来源:https://stackoverflow.com/questions/11267026/jit-saving-spacetree-as-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!