1 回答

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個贊
那是因?yàn)槟阈枰獜哪澄镞^渡到另一物。在使路徑出現(xiàn)的情況下,即從 stroke-dasharray0 length到length length:
const lineGraph = d3.select("svg")
.append("path")
.attr("d", "M 10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80");
const length = lineGraph.node().getTotalLength();
lineGraph
.attr("stroke-dasharray", "0 " + length)
.transition()
.duration(2000)
.ease(d3.easeLinear)
.attr("stroke-dasharray", length + " " + length);
path {
stroke: black;
stroke-width: 1px;
fill: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<svg></svg>
添加回答
舉報(bào)