webweb
webweb copied to clipboard
Web::display should accept node's list, not a dict
Just another proposal:
When we want to color the nodes by their metadata, we customize the display
argument in the Web class.
See the documentation: https://webwebpage.github.io/docs/examples/add_node_metadata_categorical.html
Here, the key nodes
accepts a dict
as its value. But it may make more sense to use list
instead.
In other words, the accepted value is suggested to be:
'nodes' : [ { 'id': 0, 'cooperativity' : 'high', 'alphabeticallity' : 0, }, { 'id': 1, 'cooperativity' : 'low', 'alphabeticallity' : 1, }, { 'id': 2, 'cooperativity' : 'medium', 'alphabeticallity' : 2, } ]
This enables the data object easier to talk with the native D3.js in JavaScript. Please feel free to disagree. It’s just my own feeling.
This seems reasonable! I also think this would make things more clear about how nodes in the edgelist are assigned metadata.
If they're strings, they're assigned to either:
a) a node with name
which matches that string, or
b) no metadata
If they're 0 indexed integers, they're assigned to the value at the nodes array pointed to when treated as an index.
If they're 1 indexed integers, we treat the nodes array as "1 indexed" and they're assigned to the value at the nodes array pointed to when treated as an index.
I like the idea and there's really not much LOE here. In fact, on the python side, I think you could already do this.
I'm trying to think of whether there's a real usecase for supporting the dict
behavior too.
Either way, this is easy to support and goes to the top of the todo this. (but will come out after putting out the released and then rolled back canvas upgrade 😬)