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

javascript - Chartjs Radar - Change color of end point labels - Stack Overflow

programmeradmin0浏览0评论

I need to change the color of the labels displayed at each point on the chart, I have tried many different things without any result at all.

Image

Code

                    const CHART = document.getElementById("radar_chart");
                    Chart.defaults.scale.ticks.beginAtZero = true;
                    Chart.defaults.scale.ticks.max = 10;
                    Chart.defaults.scale.ticks.display = false;
                    Chart.defaults.scale.ticks.display = false;

                    var radar = new Chart(CHART, {
                        type: 'radar',
                        data: {
                            labels: ["Team", "Potential", "Risk", "Social", "Hype"],
                            datasets: [
                                {
                                    backgroundColor: "#2e4259cc",
                                    borderColor: "#fff",
                                    borderWidth: 3,
                                    pointBorderColor: "#fff",
                                    pointBackgroundColor: "#2e4259",
                                    pointHoverRadius: 5,
                                    data: [3, 5, 9, 5, 8]
                                }
                            ]
                        },
                        options: {
                            legend: {
                                display: false,
                                fontColor: "#fff",
                                labels: {
                                    fontColor: '#fff'
                                }
                            }
                        }
                    });

My latest effort was changing pointLabelFontColor but with no luck, i can't seem to find anything about it

I need to change the color of the labels displayed at each point on the chart, I have tried many different things without any result at all.

Image

Code

                    const CHART = document.getElementById("radar_chart");
                    Chart.defaults.scale.ticks.beginAtZero = true;
                    Chart.defaults.scale.ticks.max = 10;
                    Chart.defaults.scale.ticks.display = false;
                    Chart.defaults.scale.ticks.display = false;

                    var radar = new Chart(CHART, {
                        type: 'radar',
                        data: {
                            labels: ["Team", "Potential", "Risk", "Social", "Hype"],
                            datasets: [
                                {
                                    backgroundColor: "#2e4259cc",
                                    borderColor: "#fff",
                                    borderWidth: 3,
                                    pointBorderColor: "#fff",
                                    pointBackgroundColor: "#2e4259",
                                    pointHoverRadius: 5,
                                    data: [3, 5, 9, 5, 8]
                                }
                            ]
                        },
                        options: {
                            legend: {
                                display: false,
                                fontColor: "#fff",
                                labels: {
                                    fontColor: '#fff'
                                }
                            }
                        }
                    });

My latest effort was changing pointLabelFontColor but with no luck, i can't seem to find anything about it

Share Improve this question edited Dec 3, 2019 at 21:58 ii iml0sto1 asked Apr 10, 2018 at 20:22 ii iml0sto1ii iml0sto1 1,76220 silver badges42 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7
options:{
  scale:{
    pointLabels:{
       fontColor:"red",
    },
}

In theory this should be the configuration you should use if we follow the doc for the Linear Radial Axis

The doc is for the version 2.7.2, so I am not sure it would work for your version, or if it would be any different in older version.

options: {
        scales: {
            r: {
          
                pointLabels:{
                    color: 'rgb(54, 162, 235)',
                },

            },
}

I don’t know what version you are using, but the current configuration works for me.

发布评论

评论列表(0)

  1. 暂无评论