Chart.js:使部分标签加粗 [英] Chart.js: Make part of labels bold

查看:27
本文介绍了Chart.js:使部分标签加粗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 chartJS 中的部分标签加粗.我一直在查看文档,但我找不到任何方法.如果可能的话,我希望有人可以帮助我.:) 下面是我希望它如何工作的图片.(它是在 Photoshop 中制作的)

I want to make a part of the labels in chartJS bold. I've been looking in the documentation but I cant find of any way. I hope there is someone who can help me out if it is possible at all. :) Below is a picture of how I want it to work. (its made in photoshop)

所以我想将bar total"、bar 1"、bar 2"、bar 3"和bar 4"加粗,以便更清楚地区分小时数.

So I want to make the "bar total", "bar 1", "bar 2", "bar 3" and "bar 4" bold so the difference with the hours is more clear.

标签在我的代码中设置如下:

The labels are set in my code like this:

labels: [["bar total", "150 hour"], ["bar 1", "70 hour"], ["bar 2", "30 hour"], ["bar 3", "40 hour"], ["bar 4", "10 hour"]],

我正在使用 ChartJS 2.3.0 版.

Iam using ChartJS version 2.3.0.

有什么想法吗?

推荐答案

我对chartJS不太熟悉,但我相信你可以添加以下内容:

I'm not too familiar with chartJS but I do believe that you can add the following :

Chart.defaults.global.defaultFontStyle = 'Bold'

 options: {
    scale: {
        pointLabels :{
           fontStyle: "bold",
        }
    }
}

参考资料:1) 图表js.如何更改标签"的字体样式数组?

希望这会有所帮助!

乔尔

这篇关于Chart.js:使部分标签加粗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆