-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Graph3d setOptions throws exception setData does not exist #3251
Comments
OK, great, a |
I think you're on to something here. I must have missed this in the refactoring to |
Confirmed. This is a silly oversight. I owe you a beer for finding this. Your fix works, but I find it a very roundabout way of setting the data. I propose the following, which will do exactly the same thing: /**
* Update the options. Options will be merged with current options
*
* @param {Object} options
*/
Graph3d.prototype.setOptions = function (options) {
...
// re-load the data
//this.dataGroup.reload();
var dataTable = this.dataGroup.getDataTable();
if (dataTable) {
this.setData(dataTable);
}
...
}; This gets rid of the dependency to the I'll make a PR for this. Again, thanks for reporting. |
I like your fix much better. The circular dependency mine introduced was
not good.
Thanks for the quick fix!
|
My pleasure, but for completeness I will state that what I offered you was a workaround; the fix is forthcoming and will be in the next release.
Indeed, but that was not your fault, the circular thing was already there. Best to kill it right away, before my eyes start to bleed. |
Fix for almende#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.
A quick follow up to let you know I am trying to update the bars to reflect
data that is changing regularly. When I updated the VisDataSet the 3D graph
was not responding. I tracked it down to the subscriptions getting
corrupted somehow because of the workaround. It seems that the ‘*’ is
unsubscribed via .off and then subscribed via .on. When this happens for
some reason it loses the subscribed method _onChange that begins at line
13628 of vis.js.
// subscribe to changes in the dataset
var me = this;
this._onChange = function () {
graph3d.setData(me.dataSet);
};
this.dataSet.on('*', this._onChange);
I didn’t track it down further because when I took the workaround out to
test the updates and found that most of the time I was having to replace
over 90% of the values. So it was much faster to just setData(data) and
replace the entire dataset rather than update the individual values.
Replacing the values took 2-3 seconds to update the 3d bar chart for a
10x10 dataset where as setData with a new dataset was instantaneous.
Just thought I would let you know so that you can watch out for this when
you do the proper fix.
|
Thank you for your attention; I see the problem, it's in I would say that your solution is appropriate here. The reason that incremental updates take longer is that the graph is redrawn after every change. There are several ways around this, but your solution is by far the simplest. |
This adds a unit test for PR almende#3255 which fixes almende#3251. The unit test will fail without the PR merged. **NOTE:** This also adds module `canvas`, required for the unit test. This module proved to be quite fickly to install properly. During reviewing, please pay special attention to the proper installation of this modul. I.e. do following to test: ``` > npm install # If no errors, continue > npm test /tests/Graph3D.test.js # Run unit test isolated ```
* 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
**Note:** This is a small fix and should be easy to review. Second fix for almende#3251. In method `DataGroup.initializeData()`, if the passed `rawData` is bad for some reason, it was possible to lose the subscriptions due to early return from the method. This fix changes the order in the method so that the guard clauses execute *before* the subscription is changed.
**Note:** This is a small fix and should be easy to review. Second fix for #3251. In method `DataGroup.initializeData()`, if the passed `rawData` is bad for some reason, it was possible to lose the subscriptions due to early return from the method. This fix changes the order in the method so that the guard clauses execute *before* the subscription is changed.
* Add unit tests for Graph3D issue This adds a unit test for PR #3255 which fixes #3251. The unit test will fail without the PR merged. **NOTE:** This also adds module `canvas`, required for the unit test. This module proved to be quite fickly to install properly. During reviewing, please pay special attention to the proper installation of this modul. I.e. do following to test: ``` > npm install # If no errors, continue > npm test /tests/Graph3D.test.js # Run unit test isolated ``` * Fix for travis-cl * Add giflib to travis test definition * Add libgif to travis test definition - take 2 * Proper setup and teardown for jsdom-global * Minor fixes and cleanup
* Fix missing reference to Graph3D instance in DataGroup Fix for almende#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
* Fix missing reference to Graph3D instance in DataGroup Fix for almende#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
**Note:** This is a small fix and should be easy to review. Second fix for almende#3251. In method `DataGroup.initializeData()`, if the passed `rawData` is bad for some reason, it was possible to lose the subscriptions due to early return from the method. This fix changes the order in the method so that the guard clauses execute *before* the subscription is changed.
* Add unit tests for Graph3D issue This adds a unit test for PR almende#3255 which fixes almende#3251. The unit test will fail without the PR merged. **NOTE:** This also adds module `canvas`, required for the unit test. This module proved to be quite fickly to install properly. During reviewing, please pay special attention to the proper installation of this modul. I.e. do following to test: ``` > npm install # If no errors, continue > npm test /tests/Graph3D.test.js # Run unit test isolated ``` * Fix for travis-cl * Add giflib to travis test definition * Add libgif to travis test definition - take 2 * Proper setup and teardown for jsdom-global * Minor fixes and cleanup
I just started trying to use Graph3d yesterday and used the available example code 10_styling.html to reproduce the excpetion. Btw; nice work! I changed the example to call setBarWidth() when x or y width is changed.
I cloned the latest repository and am using the distribution:
I wanted to allow the users to dynamically set the value range for coloring. When I pass updated options to
graph3d.setOptions()
an exception is throw fromDataGroup.reload line 13850
that says DataGroup does not have a setData method. I changed reload to take agraph3d
as an argument and calledgraph3d.setData(this.dataTable)
rather thanthis.setData(dataTable)
. This seems to have the correct behavior. The graph updates and has the new value range. Or in the case of the example code below the correct bar width.Not sure if this would be the proper fix as I have just started looking at your component.
10_styling.html
10_styling.txt
The text was updated successfully, but these errors were encountered: