Skip to content

Commit 28a141c

Browse files
author
Mr. X
committed
error handling
1 parent 3a27c43 commit 28a141c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/renderers/RealLineGraph.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RealLineGraph extends RealRenderer {
1818
this.lineThickness = options.lineThickness || 0.05;
1919
this.lineColor = options.lineColor || [0, 0.5, 0];
2020
// *****DEFAULTS*****
21-
21+
2222
this._progressGraph = getProgressGraphKernel(this.gpu, this.dimensions, this.progressiveAxis, this.xOffset, this.yOffset, this.axesColor, this.bgColor);
2323
this._lastProgress = 0; // Time when the graph last progressed. Internal variable
2424
this._numProgress = 0; // Number of times the graph has progressed
@@ -41,9 +41,11 @@ class RealLineGraph extends RealRenderer {
4141
}
4242

4343
addData(value) {
44+
if (typeof value != 'number') throw 'Data value not a number.'
45+
4446
this.graphPixels = this._addData(this._cloneTexture(this.graphPixels), value, this._dataIndex++, this._lastData, this._numProgress);
4547
this._lastData = value;
46-
48+
4749
// Overflow
4850
if (this._dataIndex >= this.limits.x[1] && this.progressionMode != 'continous') {
4951
let progress = Math.ceil(this.progressiveAxis == 'y' ? this.yScaleFactor : this.xScaleFactor);
@@ -52,7 +54,7 @@ class RealLineGraph extends RealRenderer {
5254
this._cloneTexture(this.graphPixels),
5355
progress
5456
)
55-
57+
5658
this._numProgress += progress;
5759

5860
if (this.progressiveAxis == 'y') {
@@ -64,7 +66,7 @@ class RealLineGraph extends RealRenderer {
6466
this.limits.x[0] += progress / this.xScaleFactor;
6567
}
6668
}
67-
69+
6870
this._display(this.graphPixels);
6971
return this;
7072
}

0 commit comments

Comments
 (0)