小编Shu*_* Wu的帖子

在Force布局中将文本标签添加到d3节点

这是我的代码看起来,你也可以在JsFiddle上有完整的代码.我想在每个节点上都有标签,但我不能.顺便说一下,标签可以嵌入控制台的圆圈中.

var nodes = svg.selectAll("circle")
                    .data(dataset.nodes)
                    .enter()
                    .append("circle")
                    .attr("r", 10)
                    .style("fill", function(d, i){
                        return colors(i);
                    })
                    .call(force.drag);
    var label = nodes.append("svg:text")
                    .text(function (d) { return d.name; })
                    .style("text-anchor", "middle")
                    .style("fill", "#555")
                    .style("font-family", "Arial")
                    .style("font-size", 12);



    force.on("tick", function(){
        edges.attr("x1", function(d){ return d.source.x; })
             .attr("y1", function(d){ return d.source.y; })
             .attr("x2", function(d){ return d.target.x; })
             .attr("y2", function(d){ return d.target.y; });
        nodes.attr("cx", function(d){ return d.x; })
             .attr("cy", function(d){ return d.y; });
        label.attr("x", function(d){ return d.x; })
             .attr("y", function (d) {return …
Run Code Online (Sandbox Code Playgroud)

javascript text label d3.js force-layout

6
推荐指数
1
解决办法
7473
查看次数

Django 无效块标签:'endfor'

我写了这些 for 循环,但我得到了错误:Django Invalid Block Tag: 'endfor'

{ % for post in post_list %}
    <div>
    {{ post.title }}
    {{ post.created_at }}
    {{ post.photo }}
    {{ post.content }}
    </div>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

python django django-templates

5
推荐指数
1
解决办法
1900
查看次数