Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit819c241

Browse files
committed
Creating plotly-via-window module
1 parent1eff685 commit819c241

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

‎angular.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"styles": [
2424
"src/styles.css"
2525
],
26-
"scripts": []
26+
"scripts": [
27+
"node_modules/plotly.js/dist/plotly.min.js"
28+
]
2729
},
2830
"configurations": {
2931
"production": {
@@ -129,4 +131,4 @@
129131
"prefix":"plotly"
130132
}
131133
}
132-
}
134+
}

‎src/app/demo/demo.module.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import { RouterModule, Routes } from '@angular/router';
66
import{HomeComponent}from'./home/home.component';
77
import{DemoComponent}from'./demo.component';
88

9-
// import { PlotlyModule } from '../plotly/plotly.module';
10-
import{PlotlyViaCDNModule}from'../plotly-via-cdn/plotly-via-cdn.module';
9+
import{PlotlyModule}from'../plotly/plotly.module';
10+
// import { PlotlyViaCDNModule } from '../plotly-via-cdn/plotly-via-cdn.module';
11+
// import { PlotlyViaWindowModule } from '../plotly-via-window/plotly-via-window.module';
1112

1213
// Examples
1314
import{BoxPlotComponent}from'./box-plots/box-plots.component';
@@ -30,8 +31,9 @@ const demoRoutes: Routes = [
3031
imports:[
3132
CommonModule,
3233
HttpClientModule,
33-
// PlotlyModule,
34-
PlotlyViaCDNModule.forRoot({version:'latest'}),
34+
PlotlyModule,
35+
// PlotlyViaCDNModule.forRoot({version: 'latest'}),
36+
// PlotlyViaWindowModule,
3537
RouterModule.forRoot(demoRoutes,{enableTracing:true}),
3638
],
3739
declarations:[HomeComponent,DemoComponent,BoxPlotComponent,LinearChartsComponent,AjaxComponent,FancyplotComponent],
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import{NgModule,ModuleWithProviders}from'@angular/core';
2+
import{CommonModule}from'@angular/common';
3+
4+
import{PlotComponent}from'../shared/plot/plot.component';
5+
import{PlotlyService}from'../shared/plotly.service';
6+
import{SharedModule}from'../shared/shared.module';
7+
8+
9+
@NgModule({
10+
imports:[CommonModule,SharedModule],
11+
declarations:[],
12+
exports:[PlotComponent]
13+
})
14+
exportclassPlotlyViaWindowModule{
15+
constructor(){
16+
constplotly=(windowasany).Plotly;
17+
18+
if(typeofplotly==='undefined'){
19+
thrownewError(`Plotly object not found on window.`);
20+
}
21+
22+
PlotlyService.setPlotly(plotly);
23+
}
24+
25+
staticforRoot():ModuleWithProviders{
26+
return{
27+
ngModule:PlotlyViaWindowModule,
28+
providers:[PlotlyService]
29+
};
30+
}
31+
}

‎src/app/plotly/plotly.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import { PlotComponent } from '../shared/plot/plot.component';
77
import{PlotlyService}from'../shared/plotly.service';
88
import{SharedModule}from'../shared/shared.module';
99

10-
PlotlyService.setPlotly(PlotlyJS);
1110

1211
@NgModule({
1312
imports:[CommonModule,SharedModule],
1413
declarations:[],
1514
exports:[PlotComponent]
1615
})
1716
exportclassPlotlyModule{
17+
constructor(){
18+
PlotlyService.setPlotly(PlotlyJS);
19+
}
20+
1821
staticforRoot():ModuleWithProviders{
1922
return{
2023
ngModule:PlotlyModule,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp