[英]Vis.js - set graph label's font as bold
I use vis.js to display a graph.我使用vis.js来显示图表。 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 .但是,我无法更新字体粗细,例如,使用font.bold: true 。
I've also tried to use font.multi , but no luck.我也试过使用font.multi ,但没有运气。
Can you show how to set existing label as bold?你能展示如何将现有标签设置为粗体吗? (potentially as normal back too)
(也可能像正常一样回来)
You need to combine a couple of options to make it work.您需要结合几个选项才能使其工作。
A. Set font
option in node
option: A. 在
node
选项中设置font
选项:
// 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: B、在
label
选项中添加html
元素:
// 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.所以基本上,您只需要将
multi
属性指定为html
并在label
属性中添加<b>
元素和标签文本。
var options = {axisFontSize = 30} 然后传递给图形对象
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.