简体   繁体   中英

Vis.js Network: Complex / Multi Section Node labels?

For the VisJs network application I'm working on I need to be able have users edit separate parts of a node label or mutiple labels within the same node . I know that it is possible to use SVGs for the node images and have those manipulated but I was wondering if there is a cleaner way to do this.

The simplest idea in my head would be having something like node.label1, node.label2 ... Alternatively a single label would have to hold HTML DIVs of different ids that could be manipulated but I guess that wont be an option on the SVG canvas?!

Maybe I just need a hint on what to look for.

After some more thinking I found the following simple workaround: My node Objects look like this:

let node = {
 id: 1,
 title: 'New Node',
 sublabel1: 'First Label Part',
 sublabel2: 'Second Label Part',
}

node.label = node.title + '\n\n' + node.sublabel1 + '\n\n' + node.sublabel2;

The sublabels can be modified by user input and the original label component that comes with DataSet() merely assembles the inputs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM