dagre-d3 svg标签不在Meteor中渲染

时间:2016-06-25 07:27:05

标签: meteor d3.js svg dagre-d3

我无法在此处将SVG标签示例应用于:http://cpettitt.github.io/project/dagre-d3/latest/demo/svg-labels.html到Meteor中。

svg_edge_label被创建,但不知何故不会出现在边缘!知道Meteor的独特之处在于不允许渲染吗? (我的Meteor app正在使用perak:dagre-d3包)

main.html中:

<head></head>
<body></body>

main.js:

import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';

var g = new dagreD3.graphlib.Graph()
    .setGraph({})
    .setDefaultEdgeLabel(function () { return {}; });

svg_edge_label = document.createElementNS('http://www.w3.org/2000/svg', 'text');
edge_tspan = document.createElementNS('http://www.w3.org/2000/svg','tspan');
edge_tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve');
edge_tspan.setAttribute('dy', '1em');
edge_tspan.setAttribute('x', '1');
edge_link = document.createElementNS('http://www.w3.org/2000/svg', 'a');
edge_link.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'http://google.com/');
edge_link.setAttribute('target', '_blank');
edge_link.textContent = 'IE Capable Edge link';
edge_tspan.appendChild(edge_link);
svg_edge_label.appendChild(edge_tspan);

g.setNode(0, {label: "A"});
g.setNode(1, {label: "B"});
g.setNode(2, {label: "C"});

g.setEdge(0, 1, { labelType: "svg", label: svg_edge_label});

var render = new dagreD3.render();
var svg = d3.select("body").append("svg"),
    svgGroup = svg.append("g");
render(d3.select("svg g"), g);

0 个答案:

没有答案