Vis.js - 将图形标签的字体设置为粗体

问题描述 投票:1回答:1

我使用vis.js来显示图表。我知道我们可以使用以下命令更新节点:

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

但是,我无法更新字体粗细,例如,使用font.bold:true。

我也试过使用font.multi,但没有运气。

你能说明如何将现有标签设置为粗体吗? (也可能正常回来)

javascript vis.js
1个回答
1
投票

您需要结合使用几个选项才能使其正常工作。

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元素。

© www.soinside.com 2019 - 2024. All rights reserved.