【发布时间】:2019-01-02 20:34:43
【问题描述】:
我的 DOM 中有以下结构
\
我需要选择所有ipaddress 以“1.1”开头或jobid 匹配特定模式的圈子,例如“jobid_29”
如何使用 D3.js 实现这一点?
在我收到的肯定回答的背面,我希望在我的圈子中添加一个额外的功能。
当满足模式选择时,我需要为我的圈子添加动画。类似的东西 https://codepen.io/riccardoscalco/pen/GZzZRz
例如,当在输入框中输入“1.1”搜索条件时,我需要将动画应用到其 Ipaddress 以输入值开头的所有圆圈。
这是我迄今为止尝试过的,但没有成功。
html:
<label id="InteractiveSearch" style="font-weight:bold"> Interactive Seach :
</label>
<input id="searchInput" type="text" placeholder="Ipaddress or Space ID...">
脚本:
$("#searchInput").on("keyup", function () { d3.selectAll("circle[ipaddress^='" + $(this).val() +"'").attr("class","svg-triangle pulse") });`
css:
.pulse {
填充:白色;
fill-opacity: 0;
变换原点:50% 50%;
animation-duration: 2s;
动画名称:脉冲;
animation-iteration-count: infinite;
}
@keyframes pulse {
来自 {
stroke-width: 3px;
笔画不透明度:1;
transform: scale(0.3);
}
to {
stroke-width: 0;
stroke-opacity: 0;
变换:比例(2);
}
}
【问题讨论】: