D3 line

绘制线段
1.最原始的做法

<line x1="10",y1="10",x2="20",y2="20">
svg.append('line')
	.attr('x1',10)
	.attr('y1',10)
	.attr('x2',20)
	.attr('y2',20)

2.使用path

<path d="M20,20L300,100">
svg.append('path')
	.attr('d',"M20,20L300,100")

3.使用d3的线段生成器

        svg = d3.select('body')
            .append('svg')
            .attr("width",300)
            .attr('height',300)
        var lines = [[10,10],[20,20],[10,30],[20,40]]
        var linePath = d3.svg.line()
        svg.append('path')
            .attr('d',linePath(lines))
            .attr('stroke','black')
            .attr('stroke-width','3px')
            .attr('fill','none')

定义两点之间的差值方式
line.curve - set the curve interpolator.

https://github.com/d3/d3/blob/master/API.md#lines
d3.line - create a new line generator.
line - generate a line for the given dataset.
line.x - set the x accessor.
line.y - set the y accessor.
line.defined - set the defined accessor.
line.curve - set the curve interpolator.
line.context - set the rendering context.
d3.lineRadial - create a new radial line generator.
lineRadial - generate a line for the given dataset.
lineRadial.angle - set the angle accessor.
lineRadial.radius - set the radius accessor.
lineRadial.defined - set the defined accessor.
lineRadial.curve - set the curve interpolator.
lineRadial.context - set the rendering context.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值