Vis.js - set graph label's font as bold

北慕城南 提交于 2020-05-29 10:52:05

问题


I use vis.js to display a graph. I know we can update the node with:

nodes.update([{
  id: 1,
  font: {
    color: "#0d8"
  }
}]);

However, I can't update the font weight, for example, with font.bold: true.

I've also tried to use font.multi, but no luck.

Can you show how to set existing label as bold? (potentially as normal back too)


回答1:


You need to combine a couple of options to make it work.

A. Set font option in node option:

// in the option object
nodes: {
    font: {
        // required: enables displaying <b>text</b> in the label as bold text
        multi: 'html',
        // optional: use this if you want to specify the font of bold text
        bold: '16px arial black'
    }
}

B. Add html element in the label option:

// in the option object or node data object
label: `<b>${YourLabel}</b>`


So basically, you only need to specify the multi property as html and add <b> element in the label property with your label text.



来源:https://stackoverflow.com/questions/50646211/vis-js-set-graph-labels-font-as-bold

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!