]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Use correct color for legend labels (#8167)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Mon, 14 Dec 2020 21:08:40 +0000 (23:08 +0200)
committerGitHub <noreply@github.com>
Mon, 14 Dec 2020 21:08:40 +0000 (16:08 -0500)
* Legend colors fallback
* Update test

docs/docs/configuration/legend.md
src/plugins/plugin.legend.js
test/specs/plugin.legend.tests.js

index 6a4733e050c513ca60bb7e2c1f47b0daa96f19c8..5ea804066c827253602f209528ecff97f641369a 100644 (file)
@@ -52,6 +52,7 @@ The legend label configuration is nested below the legend configuration using th
 | ---- | ---- | ------- | -----------
 | `boxWidth` | `number` | `40` | Width of coloured box.
 | `boxHeight` | `number` | fontSize | Height of the coloured box.
+| `color` |[`Color`](../general/colors.md) | `defaults.color` | Color of text.
 | `font` | `Font` | `defaults.font` | See [Fonts](../general/fonts.md)
 | `padding` | `number` | `10` | Padding between rows of colored boxes.
 | `generateLabels` | `function` | | Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See [Legend Item](#legend-item-interface) for details.
@@ -66,9 +67,10 @@ The legend title configuration is nested below the legend configuration using th
 
 | Name | Type | Default | Description
 | ---- | ---- | ------- | -----------
+| `color` | [`Color`](../general/colors.md) | `defaults.color` | Color of text.
 | `display` | `boolean` | `false` | Is the legend title displayed.
 | `font` | `Font` | `defaults.font` | See [Fonts](../general/fonts.md)
-| `padding` | <code>number&#124;object</code> | `0` | Padding around the title. If specified as a number, it applies evenly to all sides.
+| `padding` | `number`\|`object` | `0` | Padding around the title. If specified as a number, it applies evenly to all sides.
 | `text` | `string` | | The string title.
 
 ## Legend Item Interface
index 7c7fb8260e3ff9945b6fa0c98104c1e3feeb3878..a1614187c467111e8aec79e7c171d1bb7da6ad6e 100644 (file)
@@ -611,5 +611,10 @@ export default {
                        position: 'center',
                        text: '',
                }
+       },
+
+       defaultRoutes: {
+               'labels.color': 'color',
+               'title.color': 'color'
        }
 };
index 2a333fed4f9bb91ab5856605827e4e94e6f6fbf7..79d149c210bc882d364d00285b29e5ca05c33793 100644 (file)
@@ -17,12 +17,14 @@ describe('Legend block tests', function() {
                        onLeave: null,
 
                        labels: {
+                               color: Chart.defaults.color,
                                boxWidth: 40,
                                padding: 10,
                                generateLabels: jasmine.any(Function)
                        },
 
                        title: {
+                               color: Chart.defaults.color,
                                display: false,
                                position: 'center',
                                text: '',