得到了在 html 中定义的图表:
<div class="chart">
<canvas
baseChart
[chartType]="'line'"
[datasets]="chartData"
[labels]="chartLabels"
[options]="chartOptions"
[legend]="true"
(chartClick)="onChartClick($event)">
</canvas>
</div>
如何在 html 中更改标签的颜色?
最佳答案
您可以通过以下方式更改图例标签的字体颜色... 在 ts 集中
chartOptions.options.legend.labels.fontColor= 'white'; //set your desired color
在你的情况下:
chartOptions = {
responsive: true,
maintainAspectRatio: false,
fontColor: 'red',
options:{
legend:{
labels:{
fontColor:'white';//change the color
}
}
}
};
关于javascript - Chart.js Canvas 更改标签颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52596932/