]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Support multiple font colors for radial chart labels (#5240)
authorLaura Cressman <lauracressman@mac.com>
Thu, 15 Feb 2018 02:22:19 +0000 (21:22 -0500)
committerEvert Timberg <evert.timberg+github@gmail.com>
Thu, 15 Feb 2018 02:22:19 +0000 (21:22 -0500)
* Support multiple font colors in array

* Address linting error

docs/axes/radial/linear.md
src/scales/scale.radialLinear.js

index adebe77cc61b62a0933620ab6f3f8d01d9b737da..14009be6a5c44ea6d354f38b95ffa47afd0d2580 100644 (file)
@@ -104,7 +104,7 @@ The following options are used to configure the point labels that are shown on t
 | Name | Type | Default | Description
 | -----| ---- | --------| -----------
 | `callback` | `Function` | | Callback function to transform data labels to point labels. The default implementation simply returns the current string.
-| `fontColor` | `Color` | `'#666'` | Font color for point labels.
+| `fontColor` | `Color/Color[]` | `'#666'` | Font color for point labels.
 | `fontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family to use when rendering labels.
 | `fontSize` | `Number` | 10 | font size in pixels
 | `fontStyle` | `String` | `'normal'` | Font style to use when rendering point labels.
index 9f59f17887a5f14b401507ea7ad04a0f75aa8bb6..e36b4e1353941582cf1514e55434e4de4c72daef 100644 (file)
@@ -237,7 +237,6 @@ module.exports = function(Chart) {
 
        function drawPointLabels(scale) {
                var ctx = scale.ctx;
-               var valueOrDefault = helpers.valueOrDefault;
                var opts = scale.options;
                var angleLineOpts = opts.angleLines;
                var pointLabelOpts = opts.pointLabels;
@@ -267,7 +266,7 @@ module.exports = function(Chart) {
                                var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
 
                                // Keep this in loop since we may support array properties here
-                               var pointLabelFontColor = valueOrDefault(pointLabelOpts.fontColor, globalDefaults.defaultFontColor);
+                               var pointLabelFontColor = helpers.valueAtIndexOrDefault(pointLabelOpts.fontColor, i, globalDefaults.defaultFontColor);
                                ctx.font = plFont.font;
                                ctx.fillStyle = pointLabelFontColor;