attrSet method
Sets the attribute with the specified name to the specified value on the selected elements and returns this selection.
selection.attrSet("color", "red".u22);
If the value is a constant, all elements are given the same attribute value; otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d), the current index (i), and the current group (nodes), with thisArg as the current DOM element (nodes[i]). The function’s return value is then used to set each element’s attribute. A null value will remove the specified attribute.
Implementation
Selection attrSet(String name, Union2<EachCallback<String?>, String>? value) {
var fullname = g.namespace(name);
return each(
value?.split(
(callback) => fullname.split(
(fullname) => attrFunctionNS(fullname, callback),
(name) => attrFunction(name, callback),
),
(value) => fullname.split(
(fullname) => attrConstantNS(fullname, value),
(name) => attrConstant(name, value),
),
) ??
fullname.split(
(fullname) => attrRemoveNS(fullname),
(name) => attrRemove(name),
),
);
}