Fix the missing apply for the color on the legend labels (#10855)

* Fix the missing apply for the color on the legend labels
* apply review
This commit is contained in:
stockiNail 2022-11-04 23:55:27 +01:00 committed by GitHub
parent b271b5098a
commit 5a90b71163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -92,7 +92,7 @@ export default class DoughnutController extends DatasetController {
generateLabels(chart) {
const data = chart.data;
if (data.labels.length && data.datasets.length) {
const {labels: {pointStyle}} = chart.legend.options;
const {labels: {pointStyle, color}} = chart.legend.options;
return data.labels.map((label, i) => {
const meta = chart.getDatasetMeta(0);
@ -102,6 +102,7 @@ export default class DoughnutController extends DatasetController {
text: label,
fillStyle: style.backgroundColor,
strokeStyle: style.borderColor,
fontColor: color,
lineWidth: style.borderWidth,
pointStyle: pointStyle,
hidden: !chart.getDataVisibility(i),

View File

@ -36,7 +36,7 @@ export default class PolarAreaController extends DatasetController {
generateLabels(chart) {
const data = chart.data;
if (data.labels.length && data.datasets.length) {
const {labels: {pointStyle}} = chart.legend.options;
const {labels: {pointStyle, color}} = chart.legend.options;
return data.labels.map((label, i) => {
const meta = chart.getDatasetMeta(0);
@ -46,6 +46,7 @@ export default class PolarAreaController extends DatasetController {
text: label,
fillStyle: style.backgroundColor,
strokeStyle: style.borderColor,
fontColor: color,
lineWidth: style.borderWidth,
pointStyle: pointStyle,
hidden: !chart.getDataVisibility(i),

View File

@ -17,6 +17,7 @@ describe('Default Configs', function() {
var expected = [{
text: 'label1',
fillStyle: 'red',
fontColor: '#666',
hidden: false,
index: 0,
strokeStyle: '#000',
@ -26,6 +27,7 @@ describe('Default Configs', function() {
}, {
text: 'label2',
fillStyle: 'green',
fontColor: '#666',
hidden: false,
index: 1,
strokeStyle: '#000',
@ -35,6 +37,7 @@ describe('Default Configs', function() {
}, {
text: 'label3',
fillStyle: 'blue',
fontColor: '#666',
hidden: false,
index: 2,
strokeStyle: '#000',
@ -90,6 +93,7 @@ describe('Default Configs', function() {
var expected = [{
text: 'label1',
fillStyle: 'red',
fontColor: '#666',
hidden: false,
index: 0,
strokeStyle: '#000',
@ -99,6 +103,7 @@ describe('Default Configs', function() {
}, {
text: 'label2',
fillStyle: 'green',
fontColor: '#666',
hidden: false,
index: 1,
strokeStyle: '#000',
@ -108,6 +113,7 @@ describe('Default Configs', function() {
}, {
text: 'label3',
fillStyle: 'blue',
fontColor: '#666',
hidden: false,
index: 2,
strokeStyle: '#000',