-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
兵人
committed
Aug 18, 2023
1 parent
8fa1e63
commit 683a81e
Showing
11 changed files
with
202,986 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
64,912 changes: 64,912 additions & 0 deletions
64,912
site/.dumi/pages/benchmark/5-gesture/f2_no_opt.js
Large diffs are not rendered by default.
Oops, something went wrong.
53,023 changes: 53,023 additions & 0 deletions
53,023
site/.dumi/pages/benchmark/5-gesture/f2_opt.js
Large diffs are not rendered by default.
Oops, something went wrong.
64,936 changes: 64,936 additions & 0 deletions
64,936
site/.dumi/pages/benchmark/5-gesture/f2_prev.js
Large diffs are not rendered by default.
Oops, something went wrong.
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,91 @@ | ||
import { delay, gestureSimulator } from '@antv/f-test-utils'; | ||
import React, { useEffect, useRef } from 'react'; | ||
import Stats from 'stats.js'; | ||
import data from '../data.json'; | ||
import { Axis, Canvas, Chart, Line, Tooltip } from './f2_opt'; | ||
// import { Axis, Canvas, Chart, Line, Tooltip } from '@antv/f2'; | ||
|
||
// @ts-ignore | ||
const stats = new Stats(); | ||
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom | ||
// const $stats = stats.dom; | ||
// $stats.style.position = 'relative'; | ||
// $stats.style.left = '0px'; | ||
// $stats.style.top = '0px'; | ||
|
||
document.body.insertBefore(stats.dom, document.body.firstChild); | ||
|
||
function renderChart(canvasEl: HTMLCanvasElement) { | ||
// 清空画布 | ||
canvasEl.width = 0; | ||
canvasEl.height = 0; | ||
|
||
function getProps(data) { | ||
const vNode = ( | ||
// @ts-ignore | ||
<Canvas | ||
context={canvasEl.getContext('2d')} | ||
pixelRatio={window.devicePixelRatio} | ||
animate={false} | ||
> | ||
<Chart data={data}> | ||
<Axis field="rate" /> | ||
<Axis field="reportDate" type="timeCat" tickCount={5} /> | ||
<Line x="reportDate" y="rate" color="codeType" /> | ||
<Tooltip></Tooltip> | ||
</Chart> | ||
</Canvas> | ||
); | ||
|
||
return vNode.props; | ||
} | ||
|
||
const props = getProps(data.data); | ||
// @ts-ignore | ||
const canvas = new Canvas(props); | ||
// @ts-ignore | ||
const gcanvas = canvas.canvas; | ||
|
||
canvas.render(); | ||
|
||
gcanvas.addEventListener('afterrender', () => { | ||
stats.update(); | ||
}); | ||
|
||
let i = 0; | ||
const loopTouchmove = () => { | ||
i++; | ||
gestureSimulator(canvasEl, 'touchmove', { | ||
x: i, | ||
y: 35, | ||
}); | ||
if (i >= canvasEl.width - 400) i = 0; | ||
window.requestAnimationFrame(loopTouchmove); | ||
}; | ||
|
||
setTimeout(async () => { | ||
gestureSimulator(canvasEl, 'touchstart', { x: 60, y: 170 }); | ||
await delay(450); | ||
loopTouchmove(); | ||
}); | ||
|
||
return canvas; | ||
} | ||
|
||
export default () => { | ||
const canvasRef = useRef<HTMLCanvasElement>(null); | ||
|
||
useEffect(() => { | ||
const canvasEl = canvasRef.current; | ||
if (!canvasEl) return; | ||
|
||
renderChart(canvasEl); | ||
}, []); | ||
|
||
return ( | ||
<div style={{ paddingTop: '50px' }}> | ||
<h2>F2 latest</h2> | ||
<canvas ref={canvasRef} style={{ width: '100%', height: '260px' }} /> | ||
</div> | ||
); | ||
}; |
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,94 @@ | ||
import { delay, gestureSimulator } from '@antv/f-test-utils'; | ||
import React, { useEffect, useRef } from 'react'; | ||
import Stats from 'stats.js'; | ||
import data from '../data.json'; | ||
import { Axis, Canvas, Chart, Line, Tooltip } from './f2_4'; | ||
// import { Axis, Canvas, Chart, Line, Tooltip } from '@antv/f2'; | ||
|
||
// @ts-ignore | ||
const stats = new Stats(); | ||
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom | ||
// const $stats = stats.dom; | ||
// $stats.style.position = 'relative'; | ||
// $stats.style.left = '0px'; | ||
// $stats.style.top = '0px'; | ||
|
||
document.body.insertBefore(stats.dom, document.body.firstChild); | ||
|
||
function renderChart(canvasEl: HTMLCanvasElement) { | ||
// 清空画布 | ||
canvasEl.width = 0; | ||
canvasEl.height = 0; | ||
|
||
function getProps(data) { | ||
const vNode = ( | ||
// @ts-ignore | ||
<Canvas | ||
context={canvasEl.getContext('2d')} | ||
pixelRatio={window.devicePixelRatio} | ||
animate={false} | ||
> | ||
<Chart data={data}> | ||
<Axis field="rate" /> | ||
<Axis field="reportDate" type="timeCat" tickCount={5} /> | ||
<Line x="reportDate" y="rate" color="codeType" /> | ||
<Tooltip></Tooltip> | ||
</Chart> | ||
</Canvas> | ||
); | ||
|
||
return vNode.props; | ||
} | ||
|
||
const props = getProps(data.data); | ||
// @ts-ignore | ||
const canvas = new Canvas(props); | ||
// @ts-ignore | ||
const gcanvas = canvas.canvas; | ||
|
||
canvas.render(); | ||
|
||
// gcanvas.addEventListener('afterrender', () => { | ||
// stats.update(); | ||
// }); | ||
gcanvas.on('afterdraw', () => { | ||
stats.update(); | ||
}); | ||
|
||
let i = 0; | ||
const loopTouchmove = () => { | ||
i++; | ||
gestureSimulator(canvasEl, 'touchmove', { | ||
x: i, | ||
y: 35, | ||
}); | ||
if (i >= canvasEl.width - 400) i = 0; | ||
window.requestAnimationFrame(loopTouchmove); | ||
}; | ||
|
||
setTimeout(async () => { | ||
gestureSimulator(canvasEl, 'touchstart', { x: 60, y: 170 }); | ||
await delay(450); | ||
loopTouchmove(); | ||
}); | ||
|
||
return canvas; | ||
} | ||
|
||
export default () => { | ||
const canvasRef = useRef<HTMLCanvasElement>(null); | ||
|
||
useEffect(() => { | ||
const canvasEl = canvasRef.current; | ||
if (!canvasEl) return; | ||
|
||
renderChart(canvasEl); | ||
}, []); | ||
|
||
return ( | ||
<div style={{ paddingTop: '50px' }}> | ||
<h2>F2 4.x</h2> | ||
<canvas ref={canvasRef} style={{ width: '100%', height: '260px' }} /> | ||
</div> | ||
); | ||
}; |
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,90 @@ | ||
import { delay, gestureSimulator } from '@antv/f-test-utils'; | ||
import React, { useEffect, useRef } from 'react'; | ||
import Stats from 'stats.js'; | ||
import data from '../data.json'; | ||
import { Axis, Canvas, Chart, Line, Tooltip } from './f2_no_opt'; | ||
// import { Axis, Canvas, Chart, Line, Tooltip } from '@antv/f2'; | ||
|
||
// @ts-ignore | ||
const stats = new Stats(); | ||
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom | ||
// const $stats = stats.dom; | ||
// $stats.style.position = 'relative'; | ||
// $stats.style.left = '0px'; | ||
// $stats.style.top = '0px'; | ||
|
||
document.body.insertBefore(stats.dom, document.body.firstChild); | ||
|
||
function renderChart(canvasEl: HTMLCanvasElement) { | ||
// 清空画布 | ||
canvasEl.width = 0; | ||
canvasEl.height = 0; | ||
|
||
function getProps(data) { | ||
const vNode = ( | ||
// @ts-ignore | ||
<Canvas | ||
context={canvasEl.getContext('2d')} | ||
pixelRatio={window.devicePixelRatio} | ||
animate={false} | ||
> | ||
<Chart data={data}> | ||
<Axis field="rate" /> | ||
<Axis field="reportDate" type="timeCat" tickCount={5} /> | ||
<Line x="reportDate" y="rate" color="codeType" /> | ||
<Tooltip></Tooltip> | ||
</Chart> | ||
</Canvas> | ||
); | ||
|
||
return vNode.props; | ||
} | ||
|
||
const props = getProps(data.data); | ||
// @ts-ignore | ||
const canvas = new Canvas(props); | ||
// @ts-ignore | ||
const gcanvas = canvas.canvas; | ||
|
||
canvas.render(); | ||
|
||
gcanvas.addEventListener('afterrender', () => { | ||
stats.update(); | ||
}); | ||
|
||
let i = 0; | ||
const loopTouchmove = () => { | ||
i++; | ||
gestureSimulator(canvasEl, 'touchmove', { | ||
x: i, | ||
y: 35, | ||
}); | ||
if (i >= canvasEl.width - 400) i = 0; | ||
window.requestAnimationFrame(loopTouchmove); | ||
}; | ||
|
||
setTimeout(async () => { | ||
gestureSimulator(canvasEl, 'touchstart', { x: 60, y: 170 }); | ||
await delay(450); | ||
loopTouchmove(); | ||
}); | ||
|
||
return canvas; | ||
} | ||
export default () => { | ||
const canvasRef = useRef<HTMLCanvasElement>(null); | ||
|
||
useEffect(() => { | ||
const canvasEl = canvasRef.current; | ||
if (!canvasEl) return; | ||
|
||
renderChart(canvasEl); | ||
}, []); | ||
|
||
return ( | ||
<div style={{ paddingTop: '50px' }}> | ||
<h2>每个元素绑定事件</h2> | ||
<canvas ref={canvasRef} style={{ width: '100%', height: '260px' }} /> | ||
</div> | ||
); | ||
}; |
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,91 @@ | ||
import { delay, gestureSimulator } from '@antv/f-test-utils'; | ||
import React, { useEffect, useRef } from 'react'; | ||
import Stats from 'stats.js'; | ||
import data from '../data.json'; | ||
import { Axis, Canvas, Chart, Line, Tooltip } from './f2_prev'; | ||
// import { Axis, Canvas, Chart, Line, Tooltip } from '@antv/f2'; | ||
|
||
// @ts-ignore | ||
const stats = new Stats(); | ||
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom | ||
// const $stats = stats.dom; | ||
// $stats.style.position = 'relative'; | ||
// $stats.style.left = '0px'; | ||
// $stats.style.top = '0px'; | ||
|
||
document.body.insertBefore(stats.dom, document.body.firstChild); | ||
|
||
function renderChart(canvasEl: HTMLCanvasElement) { | ||
// 清空画布 | ||
canvasEl.width = 0; | ||
canvasEl.height = 0; | ||
|
||
function getProps(data) { | ||
const vNode = ( | ||
// @ts-ignore | ||
<Canvas | ||
context={canvasEl.getContext('2d')} | ||
pixelRatio={window.devicePixelRatio} | ||
animate={false} | ||
> | ||
<Chart data={data}> | ||
<Axis field="rate" /> | ||
<Axis field="reportDate" type="timeCat" tickCount={5} /> | ||
<Line x="reportDate" y="rate" color="codeType" /> | ||
<Tooltip></Tooltip> | ||
</Chart> | ||
</Canvas> | ||
); | ||
|
||
return vNode.props; | ||
} | ||
|
||
const props = getProps(data.data); | ||
// @ts-ignore | ||
const canvas = new Canvas(props); | ||
// @ts-ignore | ||
const gcanvas = canvas.canvas; | ||
|
||
canvas.render(); | ||
|
||
gcanvas.addEventListener('afterrender', () => { | ||
stats.update(); | ||
}); | ||
|
||
let i = 0; | ||
const loopTouchmove = () => { | ||
i++; | ||
gestureSimulator(canvasEl, 'touchmove', { | ||
x: i, | ||
y: 35, | ||
}); | ||
if (i >= canvasEl.width - 400) i = 0; | ||
window.requestAnimationFrame(loopTouchmove); | ||
}; | ||
|
||
setTimeout(async () => { | ||
gestureSimulator(canvasEl, 'touchstart', { x: 60, y: 170 }); | ||
await delay(450); | ||
loopTouchmove(); | ||
}); | ||
|
||
return canvas; | ||
} | ||
|
||
export default () => { | ||
const canvasRef = useRef<HTMLCanvasElement>(null); | ||
|
||
useEffect(() => { | ||
const canvasEl = canvasRef.current; | ||
if (!canvasEl) return; | ||
|
||
renderChart(canvasEl); | ||
}, []); | ||
|
||
return ( | ||
<div style={{ paddingTop: '50px' }}> | ||
<h2>有问题的gesture</h2> | ||
<canvas ref={canvasRef} style={{ width: '100%', height: '260px' }} /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.