From b698f68b89d7442e6b2f5894734068125420c574 Mon Sep 17 00:00:00 2001 From: jos Date: Fri, 6 Jun 2014 12:15:49 +0200 Subject: [PATCH] Graph3d listens for changes in the dataset now --- src/graph3d/Graph3d.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/graph3d/Graph3d.js b/src/graph3d/Graph3d.js index b1eb51b9..d9727211 100644 --- a/src/graph3d/Graph3d.js +++ b/src/graph3d/Graph3d.js @@ -475,7 +475,7 @@ Graph3d.prototype.getColumnRange = function(data,column) { if (minMax.max < data[i][column]) { minMax.max = data[i][column]; } } return minMax; -} +}; /** * Initialize the data from the data table. Calculate minimum and maximum values @@ -484,6 +484,12 @@ Graph3d.prototype.getColumnRange = function(data,column) { * @param {Number} style Style Number */ Graph3d.prototype._dataInitialize = function (rawData, style) { + var me = this; + + // unsubscribe from the dataTable + if (this.dataSet) { + this.dataSet.off('*', this._onChange); + } if (rawData === undefined) return; @@ -503,8 +509,15 @@ Graph3d.prototype._dataInitialize = function (rawData, style) { if (data.length == 0) return; + this.dataSet = rawData; this.dataTable = data; + // subscribe to changes in the dataset + this._onChange = function () { + me.setData(me.dataSet); + }; + this.dataSet.on('*', this._onChange); + // _determineColumnIndexes // getNumberOfRows (points) // getNumberOfColumns (x,y,z,v,t,t1,t2...) @@ -524,7 +537,6 @@ Graph3d.prototype._dataInitialize = function (rawData, style) { if (data[0].hasOwnProperty("filter")) { if (this.dataFilter === undefined) { this.dataFilter = new Filter(rawData, this.colFilter, this); - var me = this; this.dataFilter.setOnLoadCallback(function() {me.redraw();}); } }