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
Rename "map" to "datum". #45
Comments
So would |
/cc @shawnbot |
See also #470. The main design concern that is stalling this issue is the return value of
I think the most consistent approach, based on the behavior of D3's other methods, is # 2. You might be thinking that # 1 is the most consistent approach, but consider: when set a value via The downside of # 2 is that there's no way to get the data from the other groups when you have a hierarchical selection, such as |
I think there's a related issue that D3 overrides the behavior of array.map, introducing its own method. That's an interesting point. I think in the 3.0 release, it might make more sense to rename |
BTW, I will also point out that you can all array.map on a selection's sub-arrays. For example: var table = d3.select("table"),
columns = table.selectAll("thead th")[0].map(function() { return this.textContent; }); |
I vote 2. jQuery.data() behaves more like option 1, but I don't think it's comparable because d3's setter behaves so differently. You can get the behavior of option 3 like this, right? d3.selectAll("ul").selectAll("li").map(function(d, i) {
return d3.select(this).data();
}); |
Cool, agreement! Close; replace |
Der, yeah, thanks. Looking forward to using this! |
FWIW, I wrote a little demo of how this could work with data mapped from the DOM. There's a bit that patches if (d3.version < "3.0") {
d3.selection.prototype.data = d3.selection.prototype.map;
d3.selection.prototype.map = function(map) {
var out = [];
this.each(function(d, i) {
out.push(map.call(this, d, i));
});
return out;
};
} In other words:
Or have I gotten it completely wrong? |
|
Great, thanks. The only thing that I like about |
This appears to be fixed in 3.0. |
Radial lines and areas!
For release 2.8:
data()
would return a one-dimensional array of data for the first groupdata(array)
anddata(function)
would compute the data-join [as today]data(null)
would throw an error [as today]datum
is a new alias formap
datum(function)
would evaluate a function for each selected element and set each associated datum [as today]datum(null)
would clear the bound datadatum(object)
would assign the same data to all selected elementsdatum()
would return the bound data for the first non-null node (alias fornode().__data__
)For release 3.0:
map
todatum
, removing aliasThe text was updated successfully, but these errors were encountered: