小编Dal*_*y S的帖子

如何在Arc的末尾添加文本

请在下面的代码中找到用于创建圆弧的代码,我想在圆弧的末尾(即端角)的圆内附加文本

var svgContainer = d3.select("body").append("svg")
  .append("svg:svg")
  .attr("width", 350)
  .attr("height", 350)
  .append("g")
  .attr("transform", "translate(50, 50)");

var outerRadius = 40;
var stroke = 5;

var outerArc = d3.arc()
  .innerRadius(outerRadius)
  .outerRadius(outerRadius)
  .startAngle(0)
  .endAngle(5);

svgContainer.append("path")
  .style("fill", "none")
  .style("stroke", "#0B9B29")
  .style("stroke-width", stroke)
  .attr('stroke-linejoin', 'round')
  .attr("d", outerArc());
Run Code Online (Sandbox Code Playgroud)
<head>
  <script src="https://d3js.org/d3.v4.min.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)

例如

在此处输入图片说明

html javascript d3.js

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

标签 统计

d3.js ×1

html ×1

javascript ×1