From 6dabecfc4fce0d7fc858eea0aeb3b4ded7c8bdee Mon Sep 17 00:00:00 2001 From: Eliz Date: Fri, 27 Apr 2018 19:16:45 +0300 Subject: [PATCH] Add devicePixelRatio support devicePixelRatio is required to render a chart in retina resolution --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c4c867a..65bc599 100644 --- a/index.js +++ b/index.js @@ -15,10 +15,11 @@ class ChartjsNode extends EventEmitter { * @param {number} width The width of the chart canvas. * @param {number} height The height of the chart canvas. */ - constructor(width, height) { + constructor(width, height, devicePixelRatio) { super(); this._width = width; this._height = height; + this._devicePixelRatio = devicePixelRatio || 1; } /** * @returns {Number} the width of the chart/canvas in pixels @@ -55,6 +56,7 @@ class ChartjsNode extends EventEmitter { `,[]).then(window => { + window.devicePixelRatio = this._devicePixelRatio; this._window = window; const canvas = require('canvas'); const canvasMethods = ['HTMLCanvasElement'];