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

时间:2018-06-01 14:57:58

标签: javascript vis.js

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

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

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

我还尝试使用 font.multi ,但没有运气。

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

2 个答案:

答案 0 :(得分: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元素并添加标签文本。

答案 1 :(得分:0)

var options = {axisFontSize = 30} 然后传递给图形对象

相关问题