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

Commit44acbfd

Browse files
committed
Making linter happy
1 parentbeaaf67 commit44acbfd

12 files changed

+65
-54
lines changed

‎.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
-v1-dependencies-
2828

2929
-run:npm install
30-
-run:npm install plotly.js# peer dependency
30+
-run:npm install plotly.js-dist# peer dependency
3131

3232
-save_cache:
3333
paths:

‎CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
###Changed
66
- Upgraded to angular 10.0
77
- Moving to angular library format
8+
- Changing`plotly_click` event to`plotlyClick` for consistence among other event names
89

910

1011
##[2.0.0] - 2020-02-28

‎FAQ.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ It's possible disable some plotly events returning `false` in its event. Please
77

88

99

10-
##Why using`(plotly_click)` instead of`(click)`?
10+
##Why using`(plotlyClick)` instead of`(click)`?
1111

12-
Angular uses the`(click)` directive to itself. If we use the`click` name as event alias to`plotly_click` we might get unexpected behaviour from both angular and plotly.js. We believe it is simpler to just avoid using the same name is better.
12+
Angular uses the`(click)` directive to itself. If we use the`click` name as event alias to`plotlyClick` we might get unexpected behaviour from both angular and plotly.js. We believe it is simpler to just avoid using the same name is better.
1313
Please see issue:https://github.com/plotly/angular-plotly.js/issues/63
1414

1515

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Event handlers for specific [`plotly.js` events](https://plot.ly/javascript/plot
147147
|`(autoSize)`|`Function`|`plotly_autosize`||
148148
|`(beforeExport)`|`Function`|`plotly_beforeexport`||
149149
|`(buttonClicked)`|`Function`|`plotly_buttonclicked`||
150-
|`(plotly_click)`|`Function`|`plotly_click`|[why not (click)?](FAQ.md#why-using-plotly_click-instead-of-click)|
150+
|`(plotlyClick)`|`Function`|`plotly_click`|[why not (click)?](FAQ.md#why-using-plotlyclick-instead-of-click)|
151151
|`(clickAnnotation)`|`Function`|`plotly_clickannotation`||
152152
|`(deselect)`|`Function`|`plotly_deselect`||
153153
|`(doubleClick)`|`Function`|`plotly_doubleclick`||

‎projects/plotly/src/lib/plotly-via-cdn.module.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,41 @@ export type PlotlyBundleName = 'basic' | 'cartesian' | 'geo' | 'gl3d' | 'gl2d' |
1515
exports:[PlotlyComponent],
1616
})
1717
exportclassPlotlyViaCDNModule{
18-
privatestatic_plotlyBundle?:string=null;
19-
privatestatic_plotlyVersion?:string='latest';
18+
privatestaticplotlyBundle?:string=null;
19+
privatestaticplotlyVersion='latest';
2020
publicstaticplotlyBundleNames:PlotlyBundleName[]=['basic','cartesian','geo','gl3d','gl2d','mapbox','finance'];
2121

2222
constructor(publicplotlyService:PlotlyService){
2323
PlotlyService.setModuleName('ViaCDN');
2424
}
2525

26-
staticsetPlotlyVersion(version:string){
26+
staticsetPlotlyVersion(version:string):void{
2727
constisOk=version==='latest'||/^\d\.\d{1,2}\.\d{1,2}$/.test(version);
2828
if(!isOk){
2929
thrownewError(`Invalid plotly version. Please set 'latest' or version number (i.e.: 1.4.3)`);
3030
}
3131

3232
PlotlyViaCDNModule.loadViaCDN();
33-
PlotlyViaCDNModule._plotlyVersion=version;
33+
PlotlyViaCDNModule.plotlyVersion=version;
3434
}
3535

36-
staticsetPlotlyBundle(bundle:PlotlyBundleName){
36+
staticsetPlotlyBundle(bundle:PlotlyBundleName):void{
3737
constisOk=bundle===null||PlotlyViaCDNModule.plotlyBundleNames.indexOf(bundle)>=0;
3838
if(!isOk){
3939
constnames=PlotlyViaCDNModule.plotlyBundleNames.map(n=>`"${n}"`).join(', ');
4040
thrownewError(`Invalid plotly bundle. Please set to null for full or${names} for a partial bundle.`);
4141
}
4242

43-
PlotlyViaCDNModule._plotlyBundle=bundle;
43+
PlotlyViaCDNModule.plotlyBundle=bundle;
4444
}
4545

4646
staticloadViaCDN():void{
4747
PlotlyService.setPlotly('waiting');
4848

4949
constinit=()=>{
50-
constsrc=PlotlyViaCDNModule._plotlyBundle==null
51-
?`https://cdn.plot.ly/plotly-${PlotlyViaCDNModule._plotlyVersion}.min.js`
52-
:`https://cdn.plot.ly/plotly-${PlotlyViaCDNModule._plotlyBundle}-${PlotlyViaCDNModule._plotlyVersion}.min.js`;
50+
constsrc=PlotlyViaCDNModule.plotlyBundle==null
51+
?`https://cdn.plot.ly/plotly-${PlotlyViaCDNModule.plotlyVersion}.min.js`
52+
:`https://cdn.plot.ly/plotly-${PlotlyViaCDNModule.plotlyBundle}-${PlotlyViaCDNModule.plotlyVersion}.min.js`;
5353

5454
constscript:HTMLScriptElement=document.createElement('script');
5555
script.type='text/javascript';

‎projects/plotly/src/lib/plotly.component.specs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ describe('PlotlyComponent', () => {
5656
spyOn(component,'updatePlot');
5757

5858
component.revision=0;
59-
component.ngOnChanges({'revision':newSimpleChange(null,component.revision,true)});
59+
component.ngOnChanges({revision:newSimpleChange(null,component.revision,true)});
6060
fixture.detectChanges();
6161
expect(component.updatePlot).not.toHaveBeenCalled();
6262

6363
component.revision=1;
64-
component.ngOnChanges({'revision':newSimpleChange(0,component.revision,false)});
64+
component.ngOnChanges({revision:newSimpleChange(0,component.revision,false)});
6565
fixture.detectChanges();
6666
expect(component.updatePlot).toHaveBeenCalled();
6767

6868
component.revision=2;
69-
component.ngOnChanges({'revision':newSimpleChange(1,component.revision,false)});
69+
component.ngOnChanges({revision:newSimpleChange(1,component.revision,false)});
7070
fixture.detectChanges();
7171
expect(component.updatePlot).toHaveBeenCalledTimes(2);
7272
});
@@ -137,7 +137,7 @@ describe('PlotlyComponent', () => {
137137
component.plotlyInstance=document.createElement('div')asany;
138138
component.debug=true;
139139
fixture.detectChanges();
140-
component.ngOnChanges({'debug':newSimpleChange(false,component.debug,false)});
140+
component.ngOnChanges({debug:newSimpleChange(false,component.debug,false)});
141141

142142
expect(component.updatePlot).toHaveBeenCalled();
143143
setTimeout(()=>{
@@ -173,7 +173,7 @@ describe('PlotlyComponent', () => {
173173
});
174174

175175
it('should clear all added window events on destroy',async(done)=>{
176-
constwindowListenerCount=(<any>window).eventListeners().length;
176+
constwindowListenerCount=(windowasany).eventListeners().length;
177177

178178
// make component responsive via both the lib and the component (at least 2 window events are added)
179179
component.layout={title:'responsive',autosize:true};
@@ -187,7 +187,7 @@ describe('PlotlyComponent', () => {
187187
awaitfixture.whenStable();
188188

189189
// amount of listeners should be the same as before initializing the component
190-
expect((<any>window).eventListeners().length).toEqual(windowListenerCount);
190+
expect((windowasany).eventListeners().length).toEqual(windowListenerCount);
191191

192192
done();
193193
});

‎projects/plotly/src/lib/plotly.component.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* tslint:disable component-selector no-output-native no-conflicting-lifecycle */
2+
13
import{
24
Component,
35
ElementRef,
@@ -43,10 +45,10 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
4345
@Input()style?:{[key:string]:string};
4446

4547
@Input()divId?:string;
46-
@Input()revision:number=0;
48+
@Input()revision=0;
4749
@Input()className?:string|string[];
48-
@Input()debug:boolean=false;
49-
@Input()useResizeHandler:boolean=false;
50+
@Input()debug=false;
51+
@Input()useResizeHandler=false;
5052

5153
@Input()updateOnLayoutChange=true;
5254
@Input()updateOnDataChange=true;
@@ -66,7 +68,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
6668
@Output()beforeExport=newEventEmitter();
6769
@Output()buttonClicked=newEventEmitter();
6870
@Output()click=newEventEmitter();
69-
@Output()plotly_click=newEventEmitter();
71+
@Output()plotlyClick=newEventEmitter();
7072
@Output()clickAnnotation=newEventEmitter();
7173
@Output()deselect=newEventEmitter();
7274
@Output()doubleClick=newEventEmitter();
@@ -101,20 +103,20 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
101103
publickeyValueDiffers:KeyValueDiffers,
102104
){}
103105

104-
ngOnInit(){
106+
ngOnInit():void{
105107
this.createPlot().then(()=>{
106108
constfigure=this.createFigure();
107109
this.initialized.emit(figure);
108110
});
109111

110112
if(this.click.observers.length>0){
111-
constmsg='DEPRECATED: Reconsider using `(plotly_click)` instead of `(click)` to avoid event conflict. '
113+
constmsg='DEPRECATED: Reconsider using `(plotlyClick)` instead of `(click)` to avoid event conflict. '
112114
+'Please check https://github.com/plotly/angular-plotly.js#FAQ';
113115
console.error(msg);
114116
}
115117
}
116118

117-
ngOnDestroy(){
119+
ngOnDestroy():void{
118120
if(typeofthis.resizeHandler==='function'){
119121
this.getWindow().removeEventListener('resize',this.resizeHandlerasany);
120122
this.resizeHandler=undefined;
@@ -125,7 +127,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
125127
PlotlyService.remove(this.plotlyInstance);
126128
}
127129

128-
ngOnChanges(changes:SimpleChanges){
130+
ngOnChanges(changes:SimpleChanges):void{
129131
letshouldUpdate=false;
130132

131133
constrevision:SimpleChange=changes.revision;
@@ -145,7 +147,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
145147
this.updateWindowResizeHandler();
146148
}
147149

148-
ngDoCheck(){
150+
ngDoCheck():boolean|void{
149151
if(this.updateOnlyWithRevision){
150152
returnfalse;
151153
}
@@ -211,7 +213,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
211213

212214
plotlyInstance.on('plotly_click',(data:any)=>{
213215
this.click.emit(data);
214-
this.plotly_click.emit(data);
216+
this.plotlyClick.emit(data);
215217
});
216218

217219
this.updateWindowResizeHandler();
@@ -232,7 +234,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
232234
returnfigure;
233235
}
234236

235-
updatePlot(){
237+
updatePlot():Promise<any>{
236238
if(!this.plotlyInstance){
237239
consterror=newError(`Plotly component wasn't initialized`);
238240
this.error.emit(error);
@@ -250,7 +252,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
250252
});
251253
}
252254

253-
updateWindowResizeHandler(){
255+
updateWindowResizeHandler():void{
254256
if(this.useResizeHandler){
255257
if(this.resizeHandler===undefined){
256258
this.resizeHandler=()=>this.plotly.resize(this.plotlyInstance);
@@ -264,7 +266,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
264266
}
265267
}
266268

267-
dataDifferTrackBy(_:number,item:any):any{
269+
dataDifferTrackBy(_:number,item:any):unknown{
268270
constobj=Object.assign({},item,{uid:''});
269271
returnJSON.stringify(obj);
270272
}

‎projects/plotly/src/lib/plotly.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
/* tslint:disable no-namespace ban-types */
23
exportnamespacePlotly{
34
exporttypeData=any;
45
exporttypeLayout=any;

‎projects/plotly/src/lib/plotly.module.specs.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{PlotlyModule}from"./plotly.module";
1+
import{PlotlyModule}from'./plotly.module';
22

33

44
describe('PlotlyModule',()=>{
@@ -8,13 +8,15 @@ describe('PlotlyModule', () => {
88
constmod=newPlotlyModule();
99
};
1010

11-
constmsg="Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start"
12-
+" to see how to add PlotlyJS to your project.";
11+
constmsg='Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start'
12+
+' to see how to add PlotlyJS to your project.';
1313
expect(fn).toThrowError(msg);
1414

1515

1616
constfn2=()=>{
17-
PlotlyModule.plotlyjs={plot:function(){}};
17+
PlotlyModule.plotlyjs={
18+
plot():void{}
19+
};
1820
constmod=newPlotlyModule();
1921
};
2022

‎projects/plotly/src/lib/plotly.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export class PlotlyModule {
1717

1818
constructor(){
1919
if(!this.isValid()){
20-
constmsg="Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start"
21-
+" to see how to add PlotlyJS to your project.";
20+
constmsg='Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start'
21+
+' to see how to add PlotlyJS to your project.';
2222
thrownewError(msg);
2323
}
2424

‎projects/plotly/src/lib/plotly.service.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ type PlotlyName = 'Plotly' | 'ViaCDN' | 'ViaWindow';
99
})
1010
exportclassPlotlyService{
1111
protectedstaticinstances:Plotly.PlotlyHTMLElement[]=[];
12-
protectedstatic_plotly?:any=undefined;
13-
protectedstatic_moduleName?:PlotlyName=undefined;
12+
protectedstaticplotly?:any=undefined;
13+
protectedstaticmoduleName?:PlotlyName=undefined;
1414

15-
publicstaticsetModuleName(moduleName:PlotlyName){
16-
PlotlyService._moduleName=moduleName;
15+
publicstaticsetModuleName(moduleName:PlotlyName):void{
16+
PlotlyService.moduleName=moduleName;
1717
}
1818

19-
publicstaticsetPlotly(plotly:any){
19+
publicstaticsetPlotly(plotly:any):void{
2020
if(typeofplotly==='object'&&typeofplotly.react!=='function'){
2121
thrownewError('Invalid plotly.js version. Please, use any version above 1.40.0');
2222
}
2323

24-
PlotlyService._plotly=plotly;
24+
PlotlyService.plotly=plotly;
2525
}
2626

27-
publicstaticinsert(instance:Plotly.PlotlyHTMLElement){
27+
publicstaticinsert(instance:Plotly.PlotlyHTMLElement):Plotly.PlotlyHTMLElement{
2828
constindex=PlotlyService.instances.indexOf(instance);
2929
if(index===-1){
3030
PlotlyService.instances.push(instance);
3131
}
3232
returninstance;
3333
}
3434

35-
publicstaticremove(div:Plotly.PlotlyHTMLElement){
35+
publicstaticremove(div:Plotly.PlotlyHTMLElement):void{
3636
constindex=PlotlyService.instances.indexOf(div);
3737
if(index>=0){
3838
PlotlyService.instances.splice(index,1);
39-
PlotlyService._plotly.purge(div);
39+
PlotlyService.plotly.purge(div);
4040
}
4141
}
4242

@@ -49,16 +49,16 @@ export class PlotlyService {
4949
returnundefined;
5050
}
5151

52-
publicgetPlotly(){
53-
if(typeofPlotlyService._plotly==='undefined'){
54-
constmsg=PlotlyService._moduleName==='ViaCDN'
52+
publicgetPlotly():any{
53+
if(typeofPlotlyService.plotly==='undefined'){
54+
constmsg=PlotlyService.moduleName==='ViaCDN'
5555
?`Error loading Peer dependency plotly.js from CDN url`
5656
:`Peer dependency plotly.js isn't installed`;
5757

5858
thrownewError(msg);
5959
}
6060

61-
returnPlotlyService._plotly;
61+
returnPlotlyService.plotly;
6262
}
6363

6464
protectedwaitFor(fn:()=>boolean):Promise<void>{
@@ -72,7 +72,7 @@ export class PlotlyService {
7272
}
7373

7474
// tslint:disable max-line-length
75-
publicasyncnewPlot(div:HTMLDivElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>,frames?:Partial<Plotly.Config>[]){
75+
publicasyncnewPlot(div:HTMLDivElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>,frames?:Partial<Plotly.Config>[]):Promise<any>{
7676
awaitthis.waitFor(()=>this.getPlotly()!=='waiting');
7777

7878
if(frames){
@@ -83,7 +83,7 @@ export class PlotlyService {
8383
returnthis.getPlotly().newPlot(div,data,layout,config).then(()=>PlotlyService.insert(divasany))asPromise<any>;
8484
}
8585

86-
publicplot(div:Plotly.PlotlyHTMLElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>,frames?:Partial<Plotly.Config>[]){
86+
publicplot(div:Plotly.PlotlyHTMLElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>,frames?:Partial<Plotly.Config>[]):Promise<any>{
8787
if(frames){
8888
constobj={data, layout, config, frames};
8989
returnthis.getPlotly().plot(div,obj)asPromise<any>;
@@ -92,7 +92,7 @@ export class PlotlyService {
9292
returnthis.getPlotly().plot(div,data,layout,config)asPromise<any>;
9393
}
9494

95-
publicupdate(div:Plotly.PlotlyHTMLElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>,frames?:Partial<Plotly.Config>[]){
95+
publicupdate(div:Plotly.PlotlyHTMLElement,data:Plotly.Data[],layout?:Partial<Plotly.Layout>,config?:Partial<Plotly.Config>,frames?:Partial<Plotly.Config>[]):Promise<any>{
9696
if(frames){
9797
constobj={data, layout, config, frames};
9898
returnthis.getPlotly().react(div,obj)asPromise<any>;

‎projects/plotly/tslint.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
"element",
1313
"lib",
1414
"kebab-case"
15+
],
16+
"only-arrow-functions": [
17+
true,
18+
"allow-declarations",
19+
"allow-named-functions"
1520
]
1621
}
1722
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp