From 5a90b711630824f451f800c8c91fea70abdd30fe Mon Sep 17 00:00:00 2001 From: stockiNail Date: Fri, 4 Nov 2022 23:55:27 +0100 Subject: [PATCH] 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 --- src/controllers/controller.doughnut.js | 3 ++- src/controllers/controller.polarArea.js | 3 ++- test/specs/global.defaults.tests.js | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 53666b8bc..31efea785 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -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), diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 54f522271..8684adede 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -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), diff --git a/test/specs/global.defaults.tests.js b/test/specs/global.defaults.tests.js index c46ef3a9f..fb82e9f3d 100644 --- a/test/specs/global.defaults.tests.js +++ b/test/specs/global.defaults.tests.js @@ -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',