Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "simpleheat", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A tiny JavaScript library for drawing heatmaps with Canvas", | ||
@@ -21,4 +21,4 @@ "homepage": "https://github.com/mourner/simpleheat", | ||
"devDependencies": { | ||
"eslint": "^1.7.3", | ||
"eslint-config-mourner": "^1.0.1" | ||
"eslint": "^3.13.1", | ||
"eslint-config-mourner": "^2.0.1" | ||
}, | ||
@@ -28,3 +28,4 @@ "eslintConfig": { | ||
"rules": { | ||
"new-cap": 0 | ||
"new-cap": 0, | ||
"consistent-return": 0 | ||
} | ||
@@ -31,0 +32,0 @@ }, |
@@ -54,3 +54,3 @@ 'use strict'; | ||
// create a grayscale blurred circle image that we'll use for drawing points | ||
var circle = this._circle = document.createElement('canvas'), | ||
var circle = this._circle = this._createCanvas(), | ||
ctx = circle.getContext('2d'), | ||
@@ -80,3 +80,3 @@ r2 = this._r = r + blur; | ||
// create a 256x1 gradient that we'll use to turn a grayscale heatmap into a colored one | ||
var canvas = document.createElement('canvas'), | ||
var canvas = this._createCanvas(), | ||
ctx = canvas.getContext('2d'), | ||
@@ -89,3 +89,3 @@ gradient = ctx.createLinearGradient(0, 0, 0, 256); | ||
for (var i in grad) { | ||
gradient.addColorStop(i, grad[i]); | ||
gradient.addColorStop(+i, grad[i]); | ||
} | ||
@@ -134,3 +134,13 @@ | ||
} | ||
}, | ||
_createCanvas: function () { | ||
if (typeof document !== 'undefined') { | ||
return document.createElement('canvas'); | ||
} else { | ||
// create a new canvas instance in node.js | ||
// the canvas class needs to have a default constructor without any parameter | ||
return new this._canvas.constructor(); | ||
} | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47105
7
150