图表js。如何更改“标签”的字体样式阵列? [英] Chart js. How to change font styles for "labels" array?

查看:89
本文介绍了图表js。如何更改“标签”的字体样式阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Chart JS库中得到了一个图表。
截图

I got a chart from Chart JS library. Screenshot

var ctx = document.getElementById("myChart");
    var data = {
    labels: ["HTML", "CSS", "JavaScript", "jQuery", "Bootstrap", "Gulp", "PHP", 'SQL', 'Git'],
    datasets: [
        {
            defaultFontColor: 'red',
            backgroundColor: "rgba(0,255,255,.4)",
            borderColor: "rgba(0,255,255,.4)",
            pointBackgroundColor: "red",
            pointBorderColor: "#fff",
            lineTension: 0,
            pointHoverBackgroundColor: "#fff",
            pointHoverBorderColor: "rgba(179,181,198,1)",
            data: [95, 99, 60, 91, 36, 95, 40, 95, 95]
            }
        ]
    };
    var myRadarChart = new Chart(ctx, {
      type: 'radar',
      data: data,
      options: {
        responsive: true,
        scale: {
            reverse: false,
            ticks: {
                // defaultFontSize: true
            }
        }
      }
    });

我需要更改带下划线标签的字体样式。我挖过文档,我尽我所能。即使是全局字体设置也没有改变标签样式,尽管它适用于其他文本。你遇到过这样的问题吗?谢谢。

I need to change font styles for underlined labels. I've dug over documentation and i tried all what i could. Even global font settings didn't change label styles, though it worked for the rest of other text. Have you met such a problem? Thanks.

推荐答案

它隐藏得很好,但你可以在点标签选项下找到它

It's well hidden, but you can find this under "Point Label Options"

http://www.chartjs.org/ docs / #scale-radial-linear-scale

这是一个例子:
https://jsfiddle.net/qvrt01jp/1/

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

如果设置如下,全局也应该有效:

global should also work if set it like this:

Chart.defaults.global.defaultFontStyle = 'italic'

这篇关于图表js。如何更改“标签”的字体样式阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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