【问题标题】:How to blink nodes after successfully get position of nodes?成功获取节点位置后如何闪烁节点?
【发布时间】:2015-09-14 08:23:46
【问题描述】:

我正在使用 d3js 并使用 gcircle 设置 svg 我已成功完成所有操作,从 json 获取记录将节点位置设置为正确的行但是我想在设置到指定位置后通过增加半径和减少半径来闪烁节点,直到我点击任何节点。

我该怎么做?

【问题讨论】:

  • 我已经使用了这个例子bl.ocks.org/mbostock/1095795一切运行良好只是想同时闪烁这三个节点。
  • 你说除非你点击它,否则它们应该一直闪烁......?
  • 是的,它们必须一直闪烁,除非我点击其中任何一个。
  • 很高兴为您提供帮助:)

标签: javascript jquery css json d3.js


【解决方案1】:

绝对正确,因为 MKA 为您提供了解决方案,只需按照步骤实施即可。

只需创建 css 类名称节点并将该类设置在您的圈子中

.node {
            fill: #000;
            stroke: #fff;
            stroke-width: 1.5px;
        }

现在在你的圈子中设置类节点,正如你提到的你正在使用圈子

var node = svg.selectAll(".node")
                .data(json.nodes)
                .enter().append("g");

node.append("circle")
             .attr('class', 'node')
             .attr("r", your value);

并在创建函数闪烁后调用:

 force
            .nodes(nodes)
            .links(links)
            .alpha(0.1)
            .friction(0.3)
            .gravity(0.3)
            .theta(1)
            .on("tick", tick)
            .start();
            blink();  //Here it is called

//闪烁效果函数

 function blink() {
            for (i = 0; i != 30; i++) {
                $('.node').fadeTo('slow', 0.1).fadeTo('slow', 5.0);
            }
        }

【讨论】:

  • 也非常感谢 0MV1。
  • @OMV1,如果我只想让某些特定节点闪烁怎么办?例如。 if (node. == "abc") 只闪烁那个节点
  • @sigmabeta 我对设置特定名称一无所知,但就我而言,我只是在 json 中设置了一个属性 = true,通过它我刚刚检查了该属性是否为真并将这些节点设置为可闪烁。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-01
  • 2011-10-28
  • 2019-01-14
  • 2018-02-07
  • 2013-07-29
  • 2019-04-02
  • 2013-01-16
相关资源
最近更新 更多