};
helpers.callback = function(fn, args, thisArg) {
if (fn && typeof fn.call === 'function') {
- fn.apply(thisArg, args);
+ return fn.apply(thisArg, args);
}
};
helpers.getHoverColor = function(colorValue) {
beforeBuildLabels: noop,
buildLabels: function() {
var me = this;
- var labelOpts = me.options.labels;
- var legendItems = labelOpts.generateLabels.call(me, me.chart);
+ var labelOpts = me.options.labels || {};
+ var legendItems = helpers.callback(labelOpts.generateLabels, [me.chart], me) || [];
if (labelOpts.filter) {
legendItems = legendItems.filter(function(item) {
}]);
});
+ it('should not throw when the label options are missing', function() {
+ var makeChart = function() {
+ window.acquireChart({
+ type: 'bar',
+ data: {
+ datasets: [{
+ label: 'dataset1',
+ backgroundColor: '#f31',
+ borderCapStyle: 'butt',
+ borderDash: [2, 2],
+ borderDashOffset: 5.5,
+ data: []
+ }],
+ labels: []
+ },
+ options: {
+ legend: {
+ labels: false,
+ }
+ }
+ });
+ };
+ expect(makeChart).not.toThrow();
+ });
+
it('should draw correctly', function() {
var chart = window.acquireChart({
type: 'bar',