Skip to content

Commit

Permalink
Fix the missing apply for the color on the legend labels (#10855)
Browse files Browse the repository at this point in the history
* Fix the missing apply for the color on the legend labels
* apply review
  • Loading branch information
stockiNail authored Nov 4, 2022
1 parent b271b50 commit 5a90b71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/controllers/controller.doughnut.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/controller.polarArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions test/specs/global.defaults.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('Default Configs', function() {
var expected = [{
text: 'label1',
fillStyle: 'red',
fontColor: '#666',
hidden: false,
index: 0,
strokeStyle: '#000',
Expand All @@ -26,6 +27,7 @@ describe('Default Configs', function() {
}, {
text: 'label2',
fillStyle: 'green',
fontColor: '#666',
hidden: false,
index: 1,
strokeStyle: '#000',
Expand All @@ -35,6 +37,7 @@ describe('Default Configs', function() {
}, {
text: 'label3',
fillStyle: 'blue',
fontColor: '#666',
hidden: false,
index: 2,
strokeStyle: '#000',
Expand Down Expand Up @@ -90,6 +93,7 @@ describe('Default Configs', function() {
var expected = [{
text: 'label1',
fillStyle: 'red',
fontColor: '#666',
hidden: false,
index: 0,
strokeStyle: '#000',
Expand All @@ -99,6 +103,7 @@ describe('Default Configs', function() {
}, {
text: 'label2',
fillStyle: 'green',
fontColor: '#666',
hidden: false,
index: 1,
strokeStyle: '#000',
Expand All @@ -108,6 +113,7 @@ describe('Default Configs', function() {
}, {
text: 'label3',
fillStyle: 'blue',
fontColor: '#666',
hidden: false,
index: 2,
strokeStyle: '#000',
Expand Down

0 comments on commit 5a90b71

Please sign in to comment.