JIT - 将Spacetree保存为图像 [英] JIT - Saving Spacetree as an image

查看:166
本文介绍了JIT - 将Spacetree保存为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaScript InfoVis Toolkit(http://thejit.org/),并且尝试保存输出到图像中的Spacetree。 Spacetree被输出到画布。这个问题真的让我很沮丧。我尝试过:

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. 在新窗口中打开画布

  2. 打开div位于新窗口中

  3. 使用Canvas2Image(http://www.nihilogic.dk/labs/canvas2image/)

这是我当前的Javascript方法(绑定到按钮):

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

推荐答案

对于将来会遇到的任何人,通过以下方式实现:

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

将标签类型更改为Native:

Changing the Label type to "Native":

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

我也抓住了画布ID(HTML 5顺便说一下),并把图像放到一个新的窗口:

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

这篇关于JIT - 将Spacetree保存为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆