Spaces:
Paused

File size: 552 Bytes
17e1ada
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let plotlyPromise: Promise<any> | null = null

export function loadPlotly() {
  if (!plotlyPromise) {
    plotlyPromise = Promise.all([
      import('plotly.js/lib/core'),
      import('plotly.js/lib/heatmap'),
      import('plotly.js/lib/scatter'),
    ]).then(([coreModule, heatmapModule, scatterModule]) => {
      const Plotly = coreModule.default ?? coreModule
      Plotly.register([
        heatmapModule.default ?? heatmapModule,
        scatterModule.default ?? scatterModule,
      ])
      return Plotly
    })
  }

  return plotlyPromise
}