GraphAlchemist / Alchemy

Other
517 stars 232 forks source link

Allow nodeCaption to accept multiple values #429

Open nunayerBeezwax opened 9 years ago

nunayerBeezwax commented 9 years ago

Given that we will be frequently dealing with datasets which lack a predefined "caption" property, it would be nice if we could caption different nodes/edges with different properties based upon some criteria. For example, if we have a graph which includes Olympic teams and athletes on those teams, we may want to caption the athletes by "name" but the teams with "country". Probably have to develop some sort of priority or ranking system, and/or default.

hdngr commented 9 years ago

@nunayerBeezwax, would this take care of it? javascript

conf = {
    ...
    nodeCaption: function(d) {
    if (d.type === "athlete") {
           return d.name    
        }
     else if (d.type === "team") {
       return d.country
        }
...
}