Fix the `readUsedSize` regular expression to correctly parse (truncate) pixel decimal values.
*/
function readUsedSize(element, property) {
var value = helpers.getStyle(element, property);
- var matches = value && value.match(/(\d+)px/);
+ var matches = value && value.match(/^(\d+)(\.\d+)?px$/);
return matches? Number(matches[1]) : undefined;
}
rw: 165, rh: 85,
});
});
+
+ // https://github.com/chartjs/Chart.js/issues/3860
+ it('should support decimal display width and/or height', function() {
+ var chart = acquireChart({
+ options: {
+ responsive: false
+ }
+ }, {
+ canvas: {
+ style: 'width: 345.42px; height: 125.42px;'
+ }
+ });
+
+ expect(chart).toBeChartOfSize({
+ dw: 345, dh: 125,
+ rw: 345, rh: 125,
+ });
+ });
});
describe('config.options.responsive: true (maintainAspectRatio: true)', function() {