-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: lineDash支持多位数组 (#1867) * chore: add changeset * fix: rendering error when line break appears at the beginning of text (#1871) * docs: 修复异常示例 * refactor: reduce global redundant code (#1872) * refactor: reduce global redundant code * chore: add changeset * fix: svg path element A command drawing abnormality (#1874) * Version Packages (#1869) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: HuangLiangchen <[email protected]> Co-authored-by: wang1212 <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4e0fe3c
commit ae89121
Showing
120 changed files
with
938 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { | ||
Canvas, | ||
ElementEvent, | ||
Rect, | ||
Group, | ||
CustomEvent, | ||
EventTarget, | ||
} from '@antv/g'; | ||
import * as tinybench from 'tinybench'; | ||
|
||
export async function event(context: { canvas: Canvas }) { | ||
const { canvas } = context; | ||
console.log(canvas); | ||
|
||
await canvas.ready; | ||
|
||
const { width, height } = canvas.getConfig(); | ||
const root = new Group(); | ||
let count = 2e4; | ||
let rects = []; | ||
let eventTargets = []; | ||
|
||
function render() { | ||
root.destroyChildren(); | ||
rects = []; | ||
|
||
for (let i = 0; i < count; i++) { | ||
const x = Math.random() * width; | ||
const y = Math.random() * height; | ||
const size = 10 + Math.random() * 40; | ||
const speed = 1 + Math.random(); | ||
|
||
const rect = new Rect({ | ||
style: { | ||
x, | ||
y, | ||
width: size, | ||
height: size, | ||
fill: 'white', | ||
stroke: '#000', | ||
lineWidth: 1, | ||
}, | ||
}); | ||
root.appendChild(rect); | ||
rects[i] = { x, y, size, speed, el: rect }; | ||
|
||
// --- | ||
const eventTarge = new EventTarget(); | ||
eventTargets.push(eventTarge); | ||
eventTarge.addEventListener(ElementEvent.BOUNDS_CHANGED, () => { | ||
// | ||
}); | ||
} | ||
} | ||
|
||
render(); | ||
canvas.appendChild(root); | ||
|
||
// benchmark | ||
// ---------- | ||
const boundsChangedEvent = new CustomEvent(ElementEvent.BOUNDS_CHANGED); | ||
boundsChangedEvent.detail = { affectChildren: true }; | ||
|
||
const bench = new tinybench.Bench({ name: 'event benchmark', time: 1e2 }); | ||
|
||
bench.add('Iterating trigger events', async () => { | ||
root.forEach((el) => { | ||
el.dispatchEvent(boundsChangedEvent); | ||
}); | ||
}); | ||
bench.add('Iterating trigger events without propagate', async () => { | ||
root.forEach((el) => { | ||
el.dispatchEvent(boundsChangedEvent, true); | ||
}); | ||
}); | ||
bench.add('Iterating over trigger events on empty objects', async () => { | ||
eventTargets.forEach((el) => { | ||
el.dispatchEvent(boundsChangedEvent); | ||
}); | ||
}); | ||
bench.add('Batch triggering events', async () => { | ||
canvas.dispatchEvent(boundsChangedEvent, true); | ||
}); | ||
|
||
await bench.run(); | ||
|
||
console.log(bench.name); | ||
console.table(bench.table()); | ||
console.log(bench.results); | ||
console.log(bench.tasks); | ||
|
||
// ---------- | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.