D3에 익숙하지 않아 케이스에 붙어 있습니다. 내 SVG에 서클을 추가하는 버튼이 있습니다.D3 selectAll은 (는) 색상이 변경됩니다.
d3.select("button#add").on("click", function()
{
svg.append('circle')
.attr('class', 'little')
.attr("cx", Math.random()*280+10)
.attr("cy",Math.random()*280+10)
.attr("r", 12);
});
이후 원을 클릭하면 색상을 변경하고 싶습니다. 어떤 이유로 코드가 이벤트를 시작하지 않습니다.
d3.selectAll(".little").on('click', function()
{
d3.select(this).style("fill", "red");
});
.attyle 대신 .attr을 사용해 보셨습니까? d3.selectAll ("circle"). attr ("class", ".little"). on (등등). – tomtomtom