How to set group color dynamically in vis.js Graph2d?

93 views Asked by At

I'm displaying data using vis.js's Graph2d component (in a react-based app). I would like to display some selected nodes in various dynamically selected colors, so a static .css definition won't work. I thought I could do this by creating a new group with an id specific to the node (the node specifies the group's id), and defining the group like this, where color is an rgb string:

newGroupDataSet._data[resultid] = { id: resultid, className: "sel", style: "stroke:" + color + " ; fill: " + color + "; opacity: 1.0;" };

The className sel is hard-coded in a .css file but not what I want to use. If I leave that out, it seems to use a built-in set of class colors (like "vis-graph-group7"). The style definition above isn't over-riding the colors in either case, though the docs seems to suggest it will. Does anyone know how to do this?

ETA: This is a package someone else wrote, and I realize now that they are using this version:

"vis": "^4.21.0-EOL"

I'm looking at newer versions and they seem somewhat incompatible.

0

There are 0 answers