Skip to content

Commit

Permalink
Prevent labels to be displayed for null data
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrunel committed Dec 5, 2017
1 parent 2d99eb4 commit a40ac53
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,21 @@ export default {
/**
* The font options used to draw the label text.
* @member {Object|Array|Function}
* @prop {Boolean} font.family - defaults to Chart.defaults.global.defaultFontFamily
* @prop {Boolean} font.size - defaults to Chart.defaults.global.defaultFontSize
* @prop {Boolean} font.style - defaults to Chart.defaults.global.defaultFontStyle
* @prop {Boolean} font.weight - defaults to 'normal'
* @prop {String} font.family - defaults to Chart.defaults.global.defaultFontFamily
* @prop {Number} font.lineHeight - defaults to 1.2
* @prop {Number} font.size - defaults to Chart.defaults.global.defaultFontSize
* @prop {String} font.style - defaults to Chart.defaults.global.defaultFontStyle
* @prop {Number} font.weight - defaults to 'normal'
* @default Chart.defaults.global.defaultFont.*
*/
font: {
family: undefined,
lineHeight: 1.2,
size: undefined,
style: undefined,
weight: null
},

/**
* The line height (in pixel) to use for multi-lines labels.
* @member {Number|Array|Function|undefined}
* @default 1.2
*/
lineHeight: 1.2,

/**
* The distance (in pixels) to pull the label away from the anchor point, the direction
* being determined by the `align` value (only applicable if `align` is `start` or `end`).
Expand Down Expand Up @@ -138,9 +133,12 @@ export default {
* @default data[index]
*/
formatter: function(value) {
if (helpers.isNullOrUndef(value)) {
return null;
}

var label = value;
var keys, klen, k;

if (helpers.isObject(value)) {
if (!helpers.isNullOrUndef(value.label)) {
label = value.label;
Expand Down

0 comments on commit a40ac53

Please sign in to comment.