admin管理员组文章数量:1292317
I am triying with this example code but it is not correct:
var aaa = ["a","b","c"];
d3.selectAll(".none").data(aaa).enter().call(function(d) {console.log(d);});
or
var aaa = ["a","b","c"];
d3.selectAll("html").data(aaa).enter().call(function(d) {console.log(d);});
I am triying with this example code but it is not correct:
var aaa = ["a","b","c"];
d3.selectAll(".none").data(aaa).enter().call(function(d) {console.log(d);});
or
var aaa = ["a","b","c"];
d3.selectAll("html").data(aaa).enter().call(function(d) {console.log(d);});
Share
Improve this question
asked Feb 19, 2016 at 16:24
tres.14159tres.14159
9302 gold badges18 silver badges32 bronze badges
3
- can you paste your plete code? I think this is not correct code – Farhan Commented Feb 19, 2016 at 16:43
- Yes, I know those codes are incorrect. How I do for correct this code? That is the question :) . – tres.14159 Commented Feb 20, 2016 at 1:49
- What are you trying to do? – Lars Kotthoff Commented Feb 20, 2016 at 4:05
2 Answers
Reset to default 7Although the answer from @HugoLasticot is very helpful and explanatory, one might add that you can use the construct call()
to run arbitrary functions.
d3node
.select(".selector")
.call((d) => console.log(d))
This might help you when debugging.
Here is the plete list of d3 functions.
D3 allows you to bind arbitrary data to a Document Object Model (DOM), and then apply data-driven transformations to the document.
You need to initiate the data join by defining the selection to which we will join data with :
var bar = chart.selectAll("div");
After, you need to join the data (defined previously) to the selection using selection.data.
var barUpdate = bar.data(data);
But the selection is empty, so you need instantiate these missing elements by appending to the enter selection.
var barEnter = barUpdate.enter().append("div");
So you will create one DOM object per data. You can set any attribute you want (class,id,...) of the associated data value, d.
barEnter.attr("class", function(d) { return d * 10 + "px"; });
Concerning your question, you could debug your data when you create each object for each data like this :
var Viz = d3.select(".myViz")
.selectAll("div")
.data(aaa)
.enter().append("div")
.attr("class", function(d) { console.log(d); });
Hope it helps.
本文标签: javascriptHow is it to debug the data() call in D3Stack Overflow
版权声明:本文标题:javascript - How is it to debug the data() call in D3? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741555680a2385140.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论