@@ -4,19 +4,26 @@ import type { IAABBBounds } from '@visactor/vutils';
44import { Bounds , isValid } from '@visactor/vutils' ;
55import type { BaseTableAPI } from '../../../ts-types/base-table' ;
66export const cancelRenderChartQueue = false ;
7- export const chartRenderKeys : string [ ] = [ ] ;
8- export const chartRenderQueueList : Chart [ ] = [ ] ;
7+ export let chartRenderKeys : string [ ] = [ ] ;
8+ export let chartRenderQueueList : Chart [ ] = [ ] ;
99interface chartRenderQueueItem {
1010 chart : Chart ;
1111}
1212//每次消费的图表数量
1313let batchRenderChartCount = 5 ;
1414let isHandlingChartQueue = false ;
15+ let requestAnimationFrameId : number ;
1516export function setBatchRenderChartCount ( count : number ) {
1617 if ( isValid ( count ) ) {
1718 batchRenderChartCount = count ;
1819 }
1920}
21+ export function clearChartRenderQueue ( ) {
22+ chartRenderKeys = [ ] ;
23+ chartRenderQueueList = [ ] ;
24+ isHandlingChartQueue = false ;
25+ cancelAnimationFrame ( requestAnimationFrameId ) ;
26+ }
2027export function IsHandlingChartQueue ( ) {
2128 return isHandlingChartQueue ;
2229}
@@ -175,7 +182,7 @@ export function startRenderChartQueue(table: any) {
175182 if ( chartRenderQueueList . length > 0 ) {
176183 // 使用 requestAnimationFrame 或 setTimeout 来调度下一批图表的渲染
177184 // requestAnimationFrame(() => renderChartQueue(table));
178- requestAnimationFrame ( ( ) => {
185+ requestAnimationFrameId = requestAnimationFrame ( ( ) => {
179186 // 从集合中获取要渲染的图表上下文
180187 const chartsToRender = chartRenderQueueList . splice ( 0 , batchRenderChartCount ) ;
181188 chartRenderKeys . splice ( 0 , batchRenderChartCount ) ;
0 commit comments