Open RenatoUtsch opened 9 years ago
I can make a pull request that fixes this on all charts.
Might look at that much later on again, but I didn't modify that because the data and foreach expects the passed data object to be an array so I didn't want to mess with possibly breaking all nvd3 installs by redoing how the data is passed in. People can just not try to do that, so it's not really hurting anything :)
Maybe removing the foreach and getting just the selection[0]? Would this cause problems? It is a bit hacky though, but better than the current situation.
I wonder if novus is using that loop for anything... @robinfhu @joshjordan thoughts?
If novus is then whatever they are doing is completely broken for a long time.
Perhaps, but this isn't a bug so much as just a design change so we should wait for them to chime in.
I was inspecting this code: https://github.com/novus/nvd3/blob/development/src/models/scatter.js#L58
And I noticed that it creates a chart for each svg that is in the selection. This allows me to do something like this: http://jsfiddle.net/rnp7xb7p/3/
I create two chart svgs with the same chart object. You can notice that the charts get all messed up because of this. Parts of the chart work on the first one and parts on the second one.
This shouldn't be allowed to happen, should it? Maybe the selection.each() should only consider the first svg of the selection and ignore the rest.
What do you guys think?