// If no style has been set on the canvas, the render size is used as display size,
// making the chart visually bigger, so let's enforce it to the "correct" values.
// See https://github.com/chartjs/Chart.js/issues/3575
- canvas.style.height = height + 'px';
- canvas.style.width = width + 'px';
+ if (!canvas.style.height && !canvas.style.width) {
+ canvas.style.height = height + 'px';
+ canvas.style.width = width + 'px';
+ }
};
// -- Canvas methods
helpers.fontString = function(pixelSize, fontStyle, fontFamily) {
document.body.removeChild(div);
});
+ it ('should leave styled height and width on canvas if explicitly set', function() {
+ var chart = window.acquireChart({}, {
+ canvas: {
+ height: 200,
+ width: 200,
+ style: 'height: 400px; width: 400px;'
+ }
+ });
+
+ helpers.retinaScale(chart, true);
+
+ var canvas = chart.canvas;
+
+ expect(canvas.style.height).toBe('400px');
+ expect(canvas.style.width).toBe('400px');
+ });
+
describe('Color helper', function() {
function isColorInstance(obj) {
return typeof obj === 'object' && obj.hasOwnProperty('values') && obj.values.hasOwnProperty('rgb');