caretSize | Number | 5 | Size, in px, of the tooltip arrow
cornerRadius | Number | 6 | Radius of tooltip corner curves
multiKeyBackground | Color | "#fff" | Color to draw behind the colored boxes when multiple items are in the tooltip
+displayColors | Boolean | true | if true, color boxes are shown in the tooltip
callbacks | Object | | See the [callbacks section](#chart-configuration-tooltip-callbacks) below
#### Tooltip Callbacks
caretSize: 5,
cornerRadius: 6,
multiKeyBackground: '#fff',
+ displayColors: true,
callbacks: {
// Args are: (tooltipItems, data)
beforeTitle: helpers.noop,
cornerRadius: tooltipOpts.cornerRadius,
backgroundColor: tooltipOpts.backgroundColor,
opacity: 0,
- legendColorBackground: tooltipOpts.multiKeyBackground
+ legendColorBackground: tooltipOpts.multiKeyBackground,
+ displayColors: tooltipOpts.displayColors
}
});
},
});
}
- // If there is more than one item, show color items
- if (active.length > 1) {
- helpers.each(tooltipItems, function(tooltipItem) {
- labelColors.push(opts.callbacks.labelColor.call(me, tooltipItem, chartInstance));
- });
- }
+ // Determine colors for boxes
+ helpers.each(tooltipItems, function(tooltipItem) {
+ labelColors.push(opts.callbacks.labelColor.call(me, tooltipItem, chartInstance));
+ });
// Build the Text Lines
helpers.extend(model, {
helpers.each(vm.beforeBody.concat(vm.afterBody), maxLineWidth);
// Body lines may include some extra width due to the color box
- widthPadding = body.length > 1 ? (bodyFontSize + 2) : 0;
+ widthPadding = vm.displayColors ? (bodyFontSize + 2) : 0;
helpers.each(body, function(bodyItem) {
helpers.each(bodyItem.before, maxLineWidth);
helpers.each(bodyItem.lines, maxLineWidth);
// Before body lines
helpers.each(vm.beforeBody, fillLineOfText);
- var drawColorBoxes = body.length > 1;
+ var drawColorBoxes = vm.displayColors;
xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0;
// Draw body lines now
backgroundColor: 'rgba(0,0,0,0.8)',
opacity: 1,
legendColorBackground: '#fff',
+ displayColors: true,
// Text
title: ['Point 2'],
backgroundColor: 'rgba(0,0,0,0.8)',
opacity: 1,
legendColorBackground: '#fff',
+ displayColors: true,
// Text
title: ['Point 2'],
afterBody: [],
footer: [],
caretPadding: 2,
- labelColors: []
+ labelColors: [{
+ borderColor: 'rgb(255, 0, 0)',
+ backgroundColor: 'rgb(0, 255, 0)'
+ }]
}));
expect(tooltip._view.x).toBeCloseToPixel(269);