-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A strange interaction with crossfilter - subtle issue in Bubble Overlay #1687
Conversation
47b7bf7
to
4701198
Compare
… data not being updated correctly in BubbleOverlay
4701198
to
1759e22
Compare
Even though work around is easy, do you think it may be a bug in |
I think it's the documented behavior, but the author probably didn't think too much about reference semantics. There is a lot of stuff which works by accident in dc.js. In this case, the object is assigned with
Since everything in JS is by reference, and The bubble overlay could have used this._g.data([data[point.name]]).append('g') That's as far as I've gotten. I'd like to set a breakpoint on the test lines you pointed out, to understand what you're talking about, since I'm surprised this is needed. |
Do all the other charts allow cloning the crossfilter data? This surprises me, because I thought there were a lot of places that rely on the data being live-updated from crossfilter. I think the actual bug here, if any, is that the bubble overlay chart is initialized with a particular set of points (California etc.) but the test uses The bubble overlay chart doesn't do any data joins; it doesn't have a way to add or remove points. Your fix causes it to substitute an empty object for any bins that have gone missing, and then presumably it coerces an undefined radius to zero. That make the test work but it's not really correct since the chart isn't designed to be used this way. Would be happy to take a PR removing |
This is a fair point that this chart - the data should always include keys corresponding to each point. Should I change the test cases to not use I have been trying various things with the code. One of them is to use without crossfilter. In our applications we routinely use simple charts, linked charts with cross filter, and linked charts where data is remote. Currently we use different libraries for each. Charts from these three libraries look and behave noticeably different. We are now starting to use dc for standalone charts as well. We achieve this by passing a fake group (with data from the backend) and a fake dimension. On another note, cloning the cross filter data does not impact any other chart (barring Sunburst that has not been tested yet) - all test cases pass, examples seem to work. So, other than this, I have not come across any case that rely on bound objects getting modified by crossfilter. Are you aware of any? |
Yeah, I think the problem with this test is the use of That's a good point that data from other backends will usually not be modified in place the way crossfilter data is. Maybe I am remembering old issues that have been resolved by now. I completely agree this should be supported! What do you mean that charts look and behave noticeably different? Does it indicate bugs in dc.js? |
I will do a PR
Because we did not use |
…ving empty bins interferes with this. See discussion in dc-js#1687
Edit: now test case has been updated, so easier to review and merge.
Most charts uses
d3.data
, however, Bubble Overlay usesd3.datum
.There are two tests to check if filtering another dimension sets few circles to zero radii:
The test cases pass - but due to a strange coincidence. To demonstrate the issue I have made a change in the test cases which should not have made any difference (ae21b7a). However, with this change the test cases fail.
Underlying issue appears to be the following:
.datum
, children inherit it..datum
of the parent node, it reflects in the children..datum
toundefined
in the parent node, the children retain the older value..datum
toundefined
we should set it to{}
(commit 1759e22).The unmodified code ties the crossfilter objects directly. When the filter is applied the tied objects get updated. This combined with the d3 behavior with
undefined
, makes the test cases succeed.Not sure since which release the underlying issue appeared - it might be a d3 behavior change in d3v4.
I realize it is lot of explaining for a single line change.