From 979b53a16fbf2edbbb29da2541d19694c7bd78ea Mon Sep 17 00:00:00 2001 From: wimrijnders Date: Sun, 16 Jul 2017 22:58:07 +0200 Subject: [PATCH] Fix missing reference to Graph3D instance in DataGroup (#3255) * Fix missing reference to Graph3D instance in DataGroup Fix for #3251 A reference was missed in DataGroup.reload() during refactoring. Rather than fix this method, it has been removed and the logic moved to `Graph3d`. This makes for somewhat cleaner code. * Fixes due to review --- lib/graph3d/DataGroup.js | 10 ---------- lib/graph3d/Graph3d.js | 9 ++++----- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/graph3d/DataGroup.js b/lib/graph3d/DataGroup.js index 6b2093b6..83823085 100644 --- a/lib/graph3d/DataGroup.js +++ b/lib/graph3d/DataGroup.js @@ -293,14 +293,4 @@ DataGroup.prototype.getDataSet = function() { }; -/** - * Reload the data - */ -DataGroup.prototype.reload = function() { - if (this.dataTable) { - this.setData(this.dataTable); - } -}; - - module.exports = DataGroup; diff --git a/lib/graph3d/Graph3d.js b/lib/graph3d/Graph3d.js index eb4d61a6..40b1ea7e 100755 --- a/lib/graph3d/Graph3d.js +++ b/lib/graph3d/Graph3d.js @@ -171,9 +171,7 @@ function Graph3d(container, data, options) { this.setOptions(options); // apply data - if (data) { - this.setData(data); - } + this.setData(data); } // Extend Graph3d with an Emitter mixin @@ -677,6 +675,8 @@ Graph3d.prototype._readData = function(data) { * @param {Array | DataSet | DataView} data */ Graph3d.prototype.setData = function (data) { + if (data === undefined || data === null) return; + this._readData(data); this.redraw(); @@ -701,8 +701,7 @@ Graph3d.prototype.setOptions = function (options) { this.setPointDrawingMethod(); this._setSize(this.width, this.height); - // re-load the data - this.dataGroup.reload(); + this.setData(this.dataGroup.getDataTable()); // start animation when option is true if (this.animationAutoStart && this.dataFilter) {