mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-06 00:14:03 +01:00
Support multiple font colors for radial chart labels (#5240)
* Support multiple font colors in array * Address linting error
This commit is contained in:
committed by
Evert Timberg
parent
584d1c646c
commit
d6ce5c0772
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user