]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix the missing apply for the color on the legend labels (#10855)
authorstockiNail <stocki.nail@gmail.com>
Fri, 4 Nov 2022 22:55:27 +0000 (23:55 +0100)
committerGitHub <noreply@github.com>
Fri, 4 Nov 2022 22:55:27 +0000 (18:55 -0400)
* Fix the missing apply for the color on the legend labels
* apply review

src/controllers/controller.doughnut.js
src/controllers/controller.polarArea.js
test/specs/global.defaults.tests.js

index 53666b8bc0e4a28111990ca63c6e9e333e672fe6..31efea7858709dd6b04895370fdf65f9141e4512 100644 (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),
index 54f522271c2cb27281b3365183b6bf66b441bb1e..8684adede5056b1b5dd02c49fb493e3087de3818 100644 (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),
index c46ef3a9fddbe4174ac0cc8bf74a358d8d223aed..fb82e9f3d0794c6593a7f085da983f0a292555ac 100644 (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',