d3.js v4 Symbols曲线添加符号
文章目录
1.
d3.symblo()
d3提供的符号的生成器,原理是通过path画出的形状;d3提供了7种不同的的符号:circle, cross, diamond, square, star, triangle, and wye,如下图;对应d3.symbols[n]中n代表的0,1,2,3,4,5,6;
2.
demo
-
曲线图标识案例,注意定位
symbol的时候要使用translatelet 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")
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论