Sha256: 9505d1d6bb2d39e9c8fa6cdac88185bac56f32e40c6a1995d0c1b465a6624702
Contents?: true
Size: 817 Bytes
Versions: 1
Compression:
Stored size: 817 Bytes
Contents
var DataGenerator = function(dataPointCount, startingValue) { this.dataPointCount = dataPointCount; this.dataSet = []; this.startingValue = startingValue || 40; } DataGenerator.prototype.getRandomizedData = function() { if (this.dataSet.length > 0) { this.dataSet = this.dataSet.slice(1); } while (this.dataSet.length < this.dataPointCount) { var lastYCoord = this.dataSet.length > 0 ? this.dataSet[this.dataSet.length - 1] : this.startingValue, newYCoord = lastYCoord + Math.random() * 8 - 4; newYCoord = Math.min(Math.max(newYCoord, 0), 100); this.dataSet.push(newYCoord); } var res = []; for (var i = 0; i < this.dataSet.length; ++i) { res.push([i, this.dataSet[i]]) } return res; } module.exports = exports = DataGenerator;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kiso_themes-1.0.2 | lib/generators/kiso_themes/templates/rails6/kiso_themes/demo/data_generator.js |