@@ -473,9 +473,9 @@ class RadialChartStage extends Stage {
473
473
this . instanceData = [ ] ;
474
474
}
475
475
476
- initialize ( benchmark , options )
476
+ async initialize ( benchmark , options )
477
477
{
478
- super . initialize ( benchmark , options ) ;
478
+ await super . initialize ( benchmark , options ) ;
479
479
480
480
const dpr = window . devicePixelRatio || 1 ;
481
481
this . canvasDPR = Math . min ( Math . floor ( dpr ) , 2 ) ; // Just use 1 or 2.
@@ -488,7 +488,8 @@ class RadialChartStage extends Stage {
488
488
this . canvasSize = new Size ( this . _canvasObject . width / this . canvasDPR , this . _canvasObject . height / this . canvasDPR ) ;
489
489
this . _complexity = 0 ;
490
490
491
- this . #startLoadingData( benchmark ) ;
491
+ await this . #loadDataJSON( ) ;
492
+ await this . #loadImages( ) ;
492
493
493
494
this . context = this . _canvasObject . getContext ( "2d" ) ;
494
495
this . context . scale ( this . canvasDPR , this . canvasDPR ) ;
@@ -504,16 +505,6 @@ class RadialChartStage extends Stage {
504
505
this . #setupCharts( ) ;
505
506
}
506
507
507
- #startLoadingData( benchmark )
508
- {
509
- setTimeout ( async ( ) => {
510
- await this . #loadDataJSON( ) ;
511
- await this . #loadImages( ) ;
512
-
513
- benchmark . readyPromise . resolve ( ) ;
514
- } , 0 ) ;
515
- }
516
-
517
508
async #loadDataJSON( )
518
509
{
519
510
const url = "resources/departements-region.json" ;
@@ -534,9 +525,8 @@ class RadialChartStage extends Stage {
534
525
async #loadImages( )
535
526
{
536
527
let promises = [ ] ;
537
- for ( const instance of this . instanceData ) {
528
+ for ( const instance of this . instanceData )
538
529
promises . push ( instance . loadImage ( ) ) ;
539
- }
540
530
541
531
await Promise . all ( promises ) ;
542
532
}
@@ -607,12 +597,6 @@ class RadialChartBenchmark extends Benchmark {
607
597
const canvas = document . getElementById ( 'stage-canvas' ) ;
608
598
super ( new RadialChartStage ( canvas ) , options ) ;
609
599
}
610
-
611
- waitUntilReady ( )
612
- {
613
- this . readyPromise = new SimplePromise ;
614
- return this . readyPromise ;
615
- }
616
600
}
617
601
618
602
window . benchmarkClass = RadialChartBenchmark ;
@@ -637,12 +621,13 @@ class FakeController {
637
621
}
638
622
639
623
// Testing
640
- window . addEventListener ( 'load' , ( ) => {
624
+ window . addEventListener ( 'load' , async ( ) => {
641
625
if ( ! ( window === window . parent ) )
642
626
return ;
643
627
644
628
var benchmark = new window . benchmarkClass ( { } ) ;
645
629
benchmark . _controller = new FakeController ( ) ;
630
+ await benchmark . initialize ( { } ) ;
646
631
647
632
benchmark . run ( ) . then ( function ( testData ) {
648
633
0 commit comments