-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathplotly.module.ts
More file actions
35 lines (29 loc) · 1.04 KB
/
plotly.module.ts
File metadata and controls
35 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { PlotlyService } from './plotly.service';
import { PlotlyComponent } from './plotly.component';
@NgModule({
imports: [PlotlyComponent],
providers: [PlotlyService],
exports: [PlotlyComponent],
})
export class PlotlyModule {
constructor(){
if (!this.isValid()) {
const msg = 'Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start'
+ ' to see how to add PlotlyJS to your project.';
throw new Error(msg);
}
}
private isValid(): boolean {
return PlotlyService.plotly !== undefined
&& (typeof PlotlyService.plotly.plot === 'function'
|| typeof PlotlyService.plotly.newPlot === 'function');
}
public static forRoot(plotlyjs: any): ModuleWithProviders<PlotlyModule> {
PlotlyService.setPlotly(plotlyjs);
return {
ngModule: PlotlyModule,
providers: [PlotlyService]
};
}
}