1.
d3.symblo()
html
d3
提供的符號的生成器,原理是經過path畫出的形狀;git
d3
提供了7種不一樣的的符號: circle, cross, diamond, square, star, triangle, and wye,
以下圖;對應d3.symbols[n]
中n
表明的0,1,2,3,4,5,6
;github
2.
demo
app
曲線圖標識案例,注意定位symbol
的時候要使用translate
dom
let n = Math.round(Math.random()*6) enterDot.append("path") .attr("class","dot") .attr("transform",function(d){return `translate(${xScale(d.x)},${yScale(d.y)})`}) .attr("d",d3.symbol().type(function (d, i) { return d3.symbols[n]; }).size(200)) .style("fill","green")
demo:https://hk-kevin.github.io/d3...code