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

Commit3fa4a6a

Browse files
committed
Making insert and remove static methods in PlotlyService
1 parentee86ccc commit3fa4a6a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

‎src/app/plotly/plot/plot.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class PlotComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
106106

107107
constfigure=this.createFigure();
108108
this.purge.emit(figure);
109-
this.plotly.remove(this.plotlyInstance);
109+
PlotlyService.remove(this.plotlyInstance);
110110
}
111111

112112
ngOnChanges(changes:SimpleChanges){

‎src/app/plotly/plotly.service.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,23 @@ export class PlotlyService {
3232
}
3333
}
3434

35+
publicstaticinsert(instance:Plotly.PlotlyHTMLElement){
36+
constindex=PlotlyService.instances.indexOf(instance);
37+
if(index===-1){
38+
PlotlyService.instances.push(instance);
39+
}
40+
returninstance;
41+
}
42+
43+
publicstaticremove(div:Plotly.PlotlyHTMLElement){
44+
constindex=PlotlyService.instances.indexOf(div);
45+
if(index>=0){
46+
PlotlyService.instances.splice(index,1);
47+
}
48+
}
49+
3550
publicnewPlot(div:HTMLDivElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>){
36-
returnthis.plotly.newPlot(div,data,layout,config).then(this.insert.bind(this));
51+
returnthis.plotly.newPlot(div,data,layout,config).then(instance=>PlotlyService.insert(instance));
3752
}
3853

3954
publicplot(div:Plotly.PlotlyHTMLElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>){
@@ -61,19 +76,4 @@ export class PlotlyService {
6176
returnundefined;
6277
}
6378

64-
publicinsert(instance:Plotly.PlotlyHTMLElement){
65-
constindex=PlotlyService.instances.indexOf(instance);
66-
if(index===-1){
67-
PlotlyService.instances.push(instance);
68-
}
69-
returninstance;
70-
}
71-
72-
publicremove(div:Plotly.PlotlyHTMLElement){
73-
constindex=PlotlyService.instances.indexOf(div);
74-
if(index>=0){
75-
PlotlyService.instances.splice(index,1);
76-
}
77-
}
78-
7979
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp