我一直试图在SVG上生成两条路径,但似乎其中一条路径略有消失。我想知道是什么导致了这个问题。我尝试过使用不同的路径绘制公式,但没有运气。代码非常简单,如下所示:
import * as d3 from "d3";
let canvas = d3.select('#canvas');
let svg = canvas.append('svg')
.attr('width',1820)
.attr('height', 790)
.style('background-color', 'black')
var pathInfo = [
{
p: 'P',
data: [[0, 40], [50, 30], [100, 50], [200, 60], [300, 90]]
},
{
p:'p2',
data: [[0, 40], [50, 30], [100, 50], [200, 60], [350, 90]]
}
]
const curve = d3.line().curve(d3.curveNatural);
svg.selectAll('path')
.data(pathInfo)
.enter()
.append('path')
.attr('d', (d)=> curve(d.data)).attr('stroke', 'white')
白猪掌柜的
相关分类