我使用vis.js来显示图表。我知道我们可以使用以下命令更新节点:
nodes.update([{
id: 1,
font: {
color: "#0d8"
}
}]);
但是,我无法更新字体粗细,例如,使用font.bold:true。
我也试过使用font.multi,但没有运气。
你能说明如何将现有标签设置为粗体吗? (也可能正常回来)
您需要结合使用几个选项才能使其正常工作。
A.在font
选项中设置node
选项:
// 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.在html
选项中添加label
元素:
// in the option object or node data object
label: `<b>${YourLabel}</b>`
所以基本上,你只需要将multi
属性指定为html
,并在<b>
属性中添加带有标签文本的label
元素。