v2 checklist
1wheel opened this issue · comments
-
insert
-
ƒ.call
andƒ.not
- still not sold on their implementation; why setd3.f.not = function(d){ return !d }
instead of calling with a string? -
translateX
/translateY
? Kind of annoying to addselection
andtransition
for each - change
loadData
to not take an array - add links to source in docs
- reorder docs - group selection modifiers, v3 functions and everything else?
- docs for
parent
- okay to remove
bower.json
? - okay to use an adult license?
- Manually add d3 dependencies to
package.json
Missing functions
selection.prop
jetpack added selection.prop
as alias for selection.property
. Much faster to type, isn't it? Also only consistent with selection.attr
, and familiar to jQuery folks.
// for everyone's sake, let's add prop as alias for property
d3.selection.prototype.prop = d3.selection.prototype.property;
selection.on
jetpack lets you set the same listener for multiple events at once, jQuery style.
selection.on('click touchend', function() {
console.log('this works on desktop AND mobile!');
});
// this tweak allows setting a listener for multiple events, jquery style
var d3_selection_on = d3.selection.prototype.on;
d3.selection.prototype.on = function(type, listener, capture) {
if (typeof type == 'string' && type.indexOf(' ') > -1) {
type = type.split(' ');
for (var i = 0; i<type.length; i++) {
d3_selection_on.apply(this, [type[i], listener, capture]);
}
} else {
d3_selection_on.apply(this, [type, listener, capture]);
}
return this;
};
- not sure who added bower.json, probably not me
- yes, adult license is ok
- translatex/translatey -- alternatives? something like
.translate(d3.f([['value', x], 0]))
- what does "instead of calling it with a string mean again? you mean instead of doing
d3.f('value', 'f.not')
?
actually, I did create bower.json. yes, fine to remove. jetpack is baked into d3 builds nowadays
The array notation for ƒ
looks interesting... but I'm not sure how we'd indicate that in .translate(d3.f([['value', x], 0]))
the 0
is a constant, not d => d[0]
. I think pretty soon we will be using fat arrows, so maybe .translate(d3.f('value', x, d => d[x, 0]))
will suffice?
Otherwise, we could stick a bunch of utility functions on d3.f
:
d3.f.not = function(d){ return !d }
d3.f.asXpos = function(d){ return [d, 0] }
d3.f.asYpos= function(d){ return [0, d] }
d3.f.run = function(d){ return d() }
d3.f.clamp = function(min, max){ return function(d){ return Math.max(min, Math.min(d, max)) } }
Sticking random functions on ƒ
seems like less API overhead than attaching them to the selection.prototype
- you'll know that they're just simple functions and not have to guess what they do.
The magic string in d3.f('value', 'f.not')
makes me a little uncomfortable... if there is ƒ.not
function you could use it for other things: numZeroScores = scores.filter(ƒ.not)
ok, we can kill magic string functions. and I'm fine with the utility functions, but I use them rarely, so we can also throw them away and I just add them if I need to.