最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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)

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)

Share Improve this question asked Jun 1, 2018 at 14:57 AlexeyAlexey 2,8423 gold badges18 silver badges37 bronze badges 2
  • Have you succeeded using DongBin Kim's answer? See also my ment to it – YakovL Commented Sep 1, 2018 at 22:02
  • Remember that setting font.bold to true is not how it is supposed to be used: this option is to change the font of <b> elements inside the label, not to enable bold (font.multi: "html" does that) – YakovL Commented Sep 1, 2018 at 22:04
Add a ment  | 

2 Answers 2

Reset to default 7

You need to bine 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.

var options = {axisFontSize = 30} and then pass to the graph object

发布评论

评论列表(0)

  1. 暂无评论