我正在学习d3.js.在下面的脚本中,当 selection.property() 被链接时, selection.transition() 似乎无法正常工作,当 selection.property() 放入 transition()。each() 时,它可以正常工作。难道我做错了什么?或者,此 过渡() 的规范是什么?
<input class="property_transition" type="checkbox">Property Transition Test</input><br>
<input class="property_transition" type="checkbox">Property Transition Test</input><br>
<input class="property_transition" type="checkbox">Property Transition Test</input><br>
<input class="property_transition" type="checkbox">Property Transition Test</input><br>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var elements = d3.selectAll(".property_transition");
elements
.transition()//.delay(function(d,i) { return i/elements.length *50; })
.property("checked", true); // <== This is NOT working.
//.each("end", function() { d3.select(this).property("checked",true); }); // <== This works!!!
</script>
使用此脚本, Chrome浏览器提供:
未捕获的TypeError:elements.transition(...)。property不是 功能
IE11给出:
对象不支持属性或方法&#39;属性&#39;
谢谢,
答案 0 :(得分:0)
简短的回答是,.property()
不是您可以在D3中转换的内容,特别是它不提供相应的功能(正如您在Chrome中提供的错误消息所示)。
一般来说,转换二元属性实际上没有意义 - 中间值是什么?