да вы можете. Но лучше использовать attr
для DOM value manipulations
и style
для css
.
svg.selectAll(".dot")
.data(data)
.enter().append("circle")
.attr("class", "dot")
.style("r", 3)
.attr("cx", function(d) {
return x(d.date);
}
)
.attr("cy", function(d) {
return y(d.value);
})
.attr("stroke", function(d) {
return color(this.parentNode.__data__.name)
})
.attr("fill", function(d) {
return color(this.parentNode.__data__.name)
})
Example использованием style
и example с помощью attr
хотя оба работают так же, но посмотрите на structure of DOM
.
Использование attr
:
`<circle class="dot" r="3" cx="0" cy="174.375" stroke="#1f77b4" fill="#1f77b4"></circle>`
Использование style
:
`<circle class="dot" cx="0" cy="174.375" stroke="#1f77b4" fill="#1f77b4" style="r: 3;"></circle>`