小编VIP*_*WAM的帖子

如何在 d3 v4 中用点数组绘制圆弧

我想从这样的点数组中绘制一条弧:

var points = [
    [
        51.93326250000001,
        21.4375
    ],
    [
        36.72733749999999,
        40.603550000000002
    ],
    [
        21.527537500000008,
        21.4144
    ]
];
Run Code Online (Sandbox Code Playgroud)

我尝试使用d3.line(),d3.curveBasis()d3.curveBundle.beta(1)

var arcPath = d3.line()
    .x(function (d) {
         return d[0];
    })
    .y(function (d) {
         return d[1];
    })
    .curve(d3.curveBasis);
    var arc = node.append('path').attr("d", arcPath(points));
Run Code Online (Sandbox Code Playgroud)

但它正在画一条曲线:

在此输入图像描述

这不是我要找的。我想要一个弧线:

在此输入图像描述

我不明白如何使用这个:

var arc = d3.arc()
    .innerRadius(180)
    .outerRadius(240)
    .startAngle(0);
Run Code Online (Sandbox Code Playgroud)

与我的观点。

javascript svg d3.js

2
推荐指数
1
解决办法
1933
查看次数

标签 统计

d3.js ×1

javascript ×1

svg ×1