Hi
I nedd to generate multiple DOM elements from a single data point.
Every minute I send data like the next format
data:{
date : '22/Nov/2014:01:56:00 +0100'
messures: { 20, 30, 50, 40}
}
And I want to draw for this single data 4 points (circles). {IsoDate, 20}, {IsoDate, 30}, {IsoDate, 50}, {IsoDate, 40}.
I want to do this:
newdata
.enter()
.append(function (d, i){
var circles = document.createElementNS('http://www.w3.org/2000/svg', 'g');
circles.setAttribute('class', 'messures');
for (var i = 0; i < d.messures.length; i++){
var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
circle.setAttribute('class', 'circle');
circle.setAttribute('cx', function(d) { return xScale(d.date); })
circle.setAttribute('cy', function(d) { return yScale(d.messures[i]); });
circles.appendChild(circle);
}
circles.selectAll('.circle');
return circles;
});
The problem is that I can set an attribute like circle.setAttribute('class', 'circle'); but not through a function like circle.setAttribute('cx', function(d) { return xScale(d.date); }).
Are there some way to do this?
Thanks
--
You received this message because you are subscribed to a topic in the Google Groups "d3-js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/d3-js/R3bzjBiR7dc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.