antvis / antvis/util

segmentArcFactory 分段过多导致计算耗时

Open
#92 1 comment 0 reactions 1 assignee Claimed by @xiaoiver View on GitHub
bug
Dominant language
TypeScript
Stars
72
Forks
28
PR merge metrics
No merged PRs in 30d

Description

Path 部分有两点需要优化:
* 计算 Arc 的包围盒与长度时,目前会分成 100 段,导致耗时很大。合理的做法是提供 `sampleSize` 参数,这样当需要高精度时就增加分段,反之可以减少
* 目前 `getPathBBoxTotalLength()` 是一个二合一的方法,但有时仅需要计算包围盒或者长度。例如初始化 Path 时仅需要包围盒,此时计算长度就会造成浪费。可以通过参数控制,例如:

```js
// 仅计算包围盒
const { x, y, width, height } = getPathBBoxTotalLength(absolutePath, { bbox: true, length: false });

// 计算时减少采样数,牺牲精度提升性能
const { x, y, width, height } = getPathBBoxTotalLength(absolutePath, { bbox: true, length: false, sampleSize: 10 });
```

另外需要性能测试。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.