layouts.update(me, me.width, me.height);
+ const area = me.chartArea;
+ const noArea = area.width <= 0 || area.height <= 0;
+
me._layers = [];
each(me.boxes, (box) => {
+ if (noArea && box.position === 'chartArea') {
+ // Skip drawing and configuring chartArea boxes when chartArea is zero or negative
+ return;
+ }
+
// configure is called twice, once in core.scale.update and once here.
// Here the boxes are fully updated and at their final positions.
if (box.configure) {
// this layout was already counted for, lets first reduce old size
chartArea[layout.pos] -= layout.size;
}
- layout.size = layout.horizontal ? box.height : box.width;
+ layout.size = layout.horizontal ? Math.min(layout.height, box.height) : Math.min(layout.width, box.width);
chartArea[layout.pos] += layout.size;
if (box.getPadding) {
maxPadding.right = Math.max(maxPadding.right, boxPadding.right);
}
- const newWidth = params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right');
- const newHeight = params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom');
+ const newWidth = Math.max(0, params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right'));
+ const newHeight = Math.max(0, params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom'));
if (newWidth !== chartArea.w || newHeight !== chartArea.h) {
chartArea.w = newWidth;
import {
callback as call, valueOrDefault, toFont, isObject,
toPadding, getRtlAdapter, overrideTextDirection, restoreTextDirection,
- INFINITY
+ clipArea, unclipArea
} from '../helpers/index';
import {_toLeftRightCenter, _alignStartEnd} from '../helpers/helpers.extras';
/**
width = me._fitCols(titleHeight, fontSize, boxWidth, itemHeight) + 10;
}
- me.width = Math.min(width, options.maxWidth || INFINITY);
- me.height = Math.min(height, options.maxHeight || INFINITY);
+ me.width = Math.min(width, options.maxWidth || me.maxWidth);
+ me.height = Math.min(height, options.maxHeight || me.maxHeight);
}
/**
}
draw() {
- if (this.options.display) {
- this._draw();
+ const me = this;
+ if (me.options.display) {
+ const ctx = me.ctx;
+ clipArea(ctx, me);
+
+ me._draw();
+
+ unclipArea(ctx);
}
}