【发布时间】:2015-06-03 04:00:00
【问题描述】:
我正在学习 d3.js。在下面的脚本中,当 selection.property() 被链接时,selection.transition() 似乎不起作用,虽然它在 selection.property() 被放入 transition().each() 时有效。难道我做错了什么?或者,这是 transition() 的规范吗?
<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浏览器给出:
未捕获的类型错误:elements.transition(...).property 不是 功能
IE11 给出:
对象不支持属性或方法'property'
谢谢,
【问题讨论】:
-
转换二进制值实际上没有意义。你应该简单地设置它。
-
我同意你的看法。它用于从上到下检查多个复选框的视觉效果。我喜欢这种效果,很抱歉,这个问题主要是出于我对 d3 工作原理的好奇:)
-
嗯
.property()不是你可以在 D3 中转换的东西,所以这是简短的回答 :) -
谢谢!你让我免于浪费时间,因为我太喜欢玩弄自己的好奇心了。
标签: google-chrome d3.js internet-explorer-11