I'm attempting to loop through X3DOM nodes in D3.js, but I'm encountering an issue.
Check out the code snippet below:
var disktransform = scene.selectAll('.disktransform');
var shape = disktransform
.datum(slices)
.selectAll('.shape')
.data(partition.nodes)
.enter()
.append('shape')
.attr('class', 'shape')
.attr('data-name', function(d, i) { return d.name + ' ' + i; })
shape
.append('appearance')
.append('material')
.attr('diffuseColor', function (d, i) { return color(d.name); })
;
d3.selectAll('shape.shape').each(function (d) { console.log(d); d.node().addEventListener('click', function (event) { alert('key'); alert(d.attr('data-name')); }); });
and the error message making reference to HTMLUnknownElement.node()
. How can I modify the code above to function correctly with X3DOM?
TypeError: d.node is not a function
at HTMLUnknownElement.<anonymous> (cross_chart.js:136)
at d3.js:962
at d3_selection_each (d3.js:968)
at Array.d3_selectionPrototype.each (d3.js:961)
at CrossChart.addPath (cross_chart.js:136)
at HTMLDivElement.<anonymous> (cross_chart.js:263)
at d3.js:962
at d3_selection_each (d3.js:968)
at Array.d3_selectionPrototype.each (d3.js:961)
at Array.CrossChart.draw (cross_chart.js:196)
(anonymous function) @ angular.js:10126
$get @ angular.js:7398
$get.Scope.$digest @ angular.js:12669
$get.Scope.$apply @ angular.js:12915
done @ angular.js:8450
completeRequest @ angular.js:8664
xhr.onreadystatechange @ angular.js:8603