I have been struggling with an issue which perhaps is really simple. The wider context is a force directed graph in which I want to generate a series of filtering buttons dynamically whose categories come from a JSON file from an external API. I want to assign each category as an argument in the call of the button, however I have not been able to do this via JS. The code that relates to that part is:
//Create TA nodes buttons dynamically
for(var ta_name in ta_nodes) {
d3.select("#controls").append("button").on("click", filterNetwork(ta_nodes[ta_name].ta_name)).html(ta_nodes[ta_name].ta_name);
}
function filterNetwork(thematic_area_filtered) {
simulation.stop();
[...]
}
Any ideas on how I could generate the button while passing ta_nodes[ta_name].ta_name to the function?
Thanks!