Skip to content

Commit 5a90b71

Browse files
authored
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
1 parent b271b50 commit 5a90b71

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/controllers/controller.doughnut.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default class DoughnutController extends DatasetController {
9292
generateLabels(chart) {
9393
const data = chart.data;
9494
if (data.labels.length && data.datasets.length) {
95-
const {labels: {pointStyle}} = chart.legend.options;
95+
const {labels: {pointStyle, color}} = chart.legend.options;
9696

9797
return data.labels.map((label, i) => {
9898
const meta = chart.getDatasetMeta(0);
@@ -102,6 +102,7 @@ export default class DoughnutController extends DatasetController {
102102
text: label,
103103
fillStyle: style.backgroundColor,
104104
strokeStyle: style.borderColor,
105+
fontColor: color,
105106
lineWidth: style.borderWidth,
106107
pointStyle: pointStyle,
107108
hidden: !chart.getDataVisibility(i),

src/controllers/controller.polarArea.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class PolarAreaController extends DatasetController {
3636
generateLabels(chart) {
3737
const data = chart.data;
3838
if (data.labels.length && data.datasets.length) {
39-
const {labels: {pointStyle}} = chart.legend.options;
39+
const {labels: {pointStyle, color}} = chart.legend.options;
4040

4141
return data.labels.map((label, i) => {
4242
const meta = chart.getDatasetMeta(0);
@@ -46,6 +46,7 @@ export default class PolarAreaController extends DatasetController {
4646
text: label,
4747
fillStyle: style.backgroundColor,
4848
strokeStyle: style.borderColor,
49+
fontColor: color,
4950
lineWidth: style.borderWidth,
5051
pointStyle: pointStyle,
5152
hidden: !chart.getDataVisibility(i),

test/specs/global.defaults.tests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('Default Configs', function() {
1717
var expected = [{
1818
text: 'label1',
1919
fillStyle: 'red',
20+
fontColor: '#666',
2021
hidden: false,
2122
index: 0,
2223
strokeStyle: '#000',
@@ -26,6 +27,7 @@ describe('Default Configs', function() {
2627
}, {
2728
text: 'label2',
2829
fillStyle: 'green',
30+
fontColor: '#666',
2931
hidden: false,
3032
index: 1,
3133
strokeStyle: '#000',
@@ -35,6 +37,7 @@ describe('Default Configs', function() {
3537
}, {
3638
text: 'label3',
3739
fillStyle: 'blue',
40+
fontColor: '#666',
3841
hidden: false,
3942
index: 2,
4043
strokeStyle: '#000',
@@ -90,6 +93,7 @@ describe('Default Configs', function() {
9093
var expected = [{
9194
text: 'label1',
9295
fillStyle: 'red',
96+
fontColor: '#666',
9397
hidden: false,
9498
index: 0,
9599
strokeStyle: '#000',
@@ -99,6 +103,7 @@ describe('Default Configs', function() {
99103
}, {
100104
text: 'label2',
101105
fillStyle: 'green',
106+
fontColor: '#666',
102107
hidden: false,
103108
index: 1,
104109
strokeStyle: '#000',
@@ -108,6 +113,7 @@ describe('Default Configs', function() {
108113
}, {
109114
text: 'label3',
110115
fillStyle: 'blue',
116+
fontColor: '#666',
111117
hidden: false,
112118
index: 2,
113119
strokeStyle: '#000',

0 commit comments

Comments
 (0)