ChartJS 如何设置图表中标签颜色?

8mmmxcuj  于 2022-11-07  发布在  Chart.js
关注(0)|答案(2)|浏览(192)

我用chartJS创建了一个图表,我想更改数据标签和日期的颜色。怎么了?

const labels = <?php echo json_encode($Date) ?>;

const data = {
    labels: labels,
    datasets: [{
        label: 'Données Vent',
        backgroundColor: 'gray',
        borderColor: 'rgb(255, 99, 132)',
        data: <?php echo json_encode($Vent) ?>,
        data: <?php echo json_encode($Rafale) ?>,
    }]
};

const config = {
    type: 'line',
    data: data,
    options: {
        color: 'white', //couleur du titre graphique
        scales: {
            y: {
                color:"white",
                beginAtZero: true
            }
        }
    },
};

const myChart = new Chart(document.getElementById('myChart'), config);
inn6fuwd

inn6fuwd1#

标签颜色更改如下:

options: { 
            legend: {
                labels: {
                    fontColor: "blue",
                    fontSize: 18
                }
            },
        }
yrefmtwq

yrefmtwq2#

@罗宾汉@皮斯图
现在终于不一样了,我是这样:

hAxis: { direction: -1,
                 textStyle: {
                    color:'white',
                 }},
        vAxis: { 
                 textStyle: {
                    color:'white',
                 }},

相关问题