11import { Injectable } from '@angular/core' ;
2- import { Plotly } from './ plotly.interface' ;
2+ import { Config , Data , Layout , PlotlyHTMLElement } from " plotly.js-dist-min" ;
33
44type PlotlyName = 'PlotlyJS' | 'ViaCDN' | 'ViaWindow' | undefined ;
55
@@ -8,7 +8,7 @@ type PlotlyName = 'PlotlyJS' | 'ViaCDN' | 'ViaWindow' | undefined;
88 providedIn : 'root'
99} )
1010export class PlotlyService {
11- protected static instances : Plotly . PlotlyHTMLElement [ ] = [ ] ;
11+ protected static instances : PlotlyHTMLElement [ ] = [ ] ;
1212 public static plotly ?: any = undefined ;
1313 protected static moduleName ?: PlotlyName = undefined ;
1414
@@ -29,23 +29,23 @@ export class PlotlyService {
2929 PlotlyService . plotly = plotly ;
3030 }
3131
32- public static insert ( instance : Plotly . PlotlyHTMLElement ) : Plotly . PlotlyHTMLElement {
32+ public static insert ( instance : PlotlyHTMLElement ) : PlotlyHTMLElement {
3333 const index = PlotlyService . instances . indexOf ( instance ) ;
3434 if ( index === - 1 ) {
3535 PlotlyService . instances . push ( instance ) ;
3636 }
3737 return instance ;
3838 }
3939
40- public static remove ( div : Plotly . PlotlyHTMLElement ) : void {
40+ public static remove ( div : PlotlyHTMLElement ) : void {
4141 const index = PlotlyService . instances . indexOf ( div ) ;
4242 if ( index >= 0 ) {
4343 PlotlyService . instances . splice ( index , 1 ) ;
4444 PlotlyService . plotly . purge ( div ) ;
4545 }
4646 }
4747
48- public getInstanceByDivId ( id : string ) : Plotly . PlotlyHTMLElement | undefined {
48+ public getInstanceByDivId ( id : string ) : PlotlyHTMLElement | undefined {
4949 for ( const instance of PlotlyService . instances ) {
5050 if ( instance && instance . id === id ) {
5151 return instance ;
@@ -81,7 +81,7 @@ export class PlotlyService {
8181 } ) ;
8282 }
8383
84- public async newPlot ( div : HTMLDivElement , data : Plotly . Data [ ] , layout ?: Partial < Plotly . Layout > , config ?: Partial < Plotly . Config > , frames ?: Partial < Plotly . Config > [ ] ) : Promise < any > {
84+ public async newPlot ( div : HTMLDivElement , data : Data [ ] , layout ?: Partial < Layout > , config ?: Partial < Config > , frames ?: Partial < Config > [ ] ) : Promise < any > {
8585 await this . waitFor ( ( ) => this . _getPlotly ( ) !== 'waiting' ) ;
8686
8787 if ( frames ) {
@@ -92,7 +92,7 @@ export class PlotlyService {
9292 return this . _getPlotly ( ) . newPlot ( div , data , layout , config ) . then ( ( ) => PlotlyService . insert ( div as any ) ) as Promise < any > ;
9393 }
9494
95- public plot ( div : Plotly . PlotlyHTMLElement , data : Plotly . Data [ ] , layout ?: Partial < Plotly . Layout > , config ?: Partial < Plotly . Config > , frames ?: Partial < Plotly . Config > [ ] ) : Promise < any > {
95+ public plot ( div : PlotlyHTMLElement , data : Data [ ] , layout ?: Partial < Layout > , config ?: Partial < Config > , frames ?: Partial < Config > [ ] ) : Promise < any > {
9696 if ( frames ) {
9797 const obj = { data, layout, config, frames } ;
9898 return this . _getPlotly ( ) . newPlot ( div , obj ) as Promise < any > ;
@@ -101,7 +101,7 @@ export class PlotlyService {
101101 return this . _getPlotly ( ) . newPlot ( div , data , layout , config ) as Promise < any > ;
102102 }
103103
104- public update ( div : Plotly . PlotlyHTMLElement , data : Plotly . Data [ ] , layout ?: Partial < Plotly . Layout > , config ?: Partial < Plotly . Config > , frames ?: Partial < Plotly . Config > [ ] ) : Promise < any > {
104+ public update ( div : PlotlyHTMLElement , data : Data [ ] , layout ?: Partial < Layout > , config ?: Partial < Config > , frames ?: Partial < Config > [ ] ) : Promise < any > {
105105 if ( frames ) {
106106 const obj = { data, layout, config, frames } ;
107107 return this . _getPlotly ( ) . react ( div , obj ) as Promise < any > ;
@@ -110,7 +110,7 @@ export class PlotlyService {
110110 return this . _getPlotly ( ) . react ( div , data , layout , config ) as Promise < any > ;
111111 }
112112
113- public resize ( div : Plotly . PlotlyHTMLElement ) : void {
113+ public resize ( div : PlotlyHTMLElement ) : void {
114114 return this . _getPlotly ( ) . Plots . resize ( div ) ;
115115 }
116116}
0 commit comments