I'm working with an array of objects that has been pulled from a database; a csv file in essence. A sample object is like this:
var data = [
{
"name" : "blah",
"number" : 1234,
"associate" : 2234
},
{
"name" : "blurg",
"number" : 2234,
"associate" : null
},
{
"name" : "blarg",
"number" : 3334,
"associate" : null
}
]
What I want to do, is draw a line or path between the objects that have an "associate", and their appropriate "parent," though it's not structured as a parent/child.
Conceptually, this is what I'm thinking:
var diagonal = d3.svg.diagonal()
.source(this)
.target(dom_element_whose_number == d.associate);
var filteredData = data.filter(function(d) { return d.associate };
svg.selectAll("path")
.data(filteredData)
.enter()
.append("path")
.attr("d", diagonal);
Any suggestions? I've been banging my head against this for a while...