Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

heatmapfromdata

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heatmapfromdata - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

81

heatmapfromdata.js

@@ -0,23 +1,41 @@

'use strict';
// за что отвечает if
if (typeof module !== 'undefined') module.exports.heatmapfromdata = heatmapfromdata;
// module.exports.heatmapfromdata = heatmapfromdata;
function Heatmapfromdata(canvas) {
function heatmapfromdata(canvas) {
if (!(this instanceof Heatmapfromdata)) return new Heatmapfromdata(canvas);
// защита от НЕПРАВИЛЬНОЙ привязки контекста
if (!(this instanceof heatmapfromdata)) return new heatmapfromdata(canvas);
canvas = typeof canvas === 'string' ? document.getElementById(canvas) : canvas;
this._self = this;
this._canvas = canvas;
this._canvas = typeof canvas === 'string' ? document.getElementById(canvas) : canvas;
this._ctx = this._canvas.getContext("2d");
this._width = this._canvas.width;
this._height = this._canvas.height;
this._data = [];
this._grad = [],
this._sizeColors = 1000;
this._width = this._canvas.width;
this._height = this._canvas.height;
this._sizeColors = 1000; // кол-ва цветов в градиенте
}
Heatmapfromdata.prototype = {
heatmapfromdata.prototype = {
resetAlfa: function() {
this._alfa = 0;
changeCanvas: function(width, height = 0) {
if (height == 0) {
this._canvas.width = width;
this._canvas.height = width;
} else {
this._canvas.width = width;
this._canvas.height = height;
}
return this;
},
sizeColors: function(sizeColors) {
this._sizeColors = sizeColors;
return this;
},
data: function(data) {

@@ -36,6 +54,9 @@ this._data = data;

draw: function(X) {
let start= new Date().getTime();
this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
let start= new Date().getTime();
var side = this._data.length,

@@ -49,2 +70,11 @@ step = 1;

var colors = this._grad[Math.trunc(X * this._data[i][j])];
try {
var asdasda = colors[0];
} catch {
console.log("X * this._data[i][j]): ", X * this._data[i][j]);
console.log("X: ", X);
console.log("i: ", i, "j ", j);
}
var R = colors[0],

@@ -61,2 +91,4 @@ G = colors[1],

console.log(`Draw: ${end - start}ms`);
return this;
},

@@ -108,23 +140,2 @@

function dataNormalization(matrix) {
let maxElem = 0.0;
for(let i = 0; i < matrix.length - 1; i++) {
for(let j = 0; j < matrix.length - 1; j++) {
maxElem = Math.max(Math.abs(matrix[i][j]), Math.abs(maxElem));
}
}
return maxElem;
};
function parseDataFromFile(data) {
return data.split("\n").map(e => {
return e.trim().slice(0).split(",").map(e => +e);
});
};
module.exports.Heatmapfromdata = Heatmapfromdata;
module.exports.parseDataFromFile = parseDataFromFile;
module.exports.dataNormalization = dataNormalization;
// module.exports.heatmapfromdata = heatmapfromdata;
{
"name": "heatmapfromdata",
"version": "1.2.0",
"version": "1.2.1",
"description": "This project draws mechanical processes",

@@ -5,0 +5,0 @@ "main": "heatmapfromdata.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc