Reputation: 2779
I have a D3 visualization of a graph where I get some data from a MySQL database. I want to create a button or something of the sort which the user can interact with (just like a button) based on the amount of data i get from my database.
For example: IF this is the array I get: [Blabla1, blabla2, blabla3]
I'll count those up and want to create 3 buttons. Is that possible in D3? I can't find anything in their documentation about buttons or likewise.
Upvotes: 2
Views: 2334
Reputation: 109232
Buttons are just DOM elements like everything else that D3 works with. There's nothing special about creating buttons as opposed to div
s, SVG circle
s or anything like that.
So your code would follow the usual pattern:
var data = [Blabla1, blabla2, blabla3];
d3.selectAll("button")
.data(data)
.enter()
.append("button")
.attr("id", function(d) { return d; })
...
Upvotes: 4