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

Commite3dfb8d

Browse files
committed
Merge branch 'master' of github.com:plotly/angular-plotly.js
2 parentsb424781 +3117051 commite3dfb8d

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

‎FAQ.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
##How to disable plotly events ?
55

66
It's possible disable some plotly events returning`false` in its event. Please see issue:https://github.com/plotly/angular-plotly.js/issues/52#issuecomment-476018478
7+
8+
9+
10+
##Why using`(plotly_click)` instead of`(click)` ?
11+
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.
13+
Please see issue:https://github.com/plotly/angular-plotly.js/issues/63
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div>
2-
<plotly-plot[data]="graph.data"[layout]="graph.layout"[revision]="0"[debug]="true"[useResizeHandler]="true"></plotly-plot>
2+
<plotly-plot(plotly_click)="onClick($event)"[data]="graph.data"[layout]="graph.layout"[revision]="0"[debug]="true"[useResizeHandler]="true"></plotly-plot>
33
</div>

‎src/app/demo/fancyplot/fancyplot.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ export class FancyplotComponent implements OnInit {
2020
ngOnInit(){
2121
}
2222

23+
onClick(event:any){
24+
console.log('click!');
25+
}
26+
2327
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class PlotComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
6363
@Output()beforeExport=newEventEmitter();
6464
@Output()buttonClicked=newEventEmitter();
6565
@Output()click=newEventEmitter();
66+
@Output()plotly_click=newEventEmitter();
6667
@Output()clickAnnotation=newEventEmitter();
6768
@Output()deselect=newEventEmitter();
6869
@Output()doubleClick=newEventEmitter();
@@ -83,7 +84,7 @@ export class PlotComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
8384
@Output()unhover=newEventEmitter();
8485

8586
publiceventNames=['afterExport','afterPlot','animated','animatingFrame','animationInterrupted','autoSize',
86-
'beforeExport','buttonClicked','click','clickAnnotation','deselect','doubleClick','framework','hover',
87+
'beforeExport','buttonClicked','clickAnnotation','deselect','doubleClick','framework','hover',
8788
'legendClick','legendDoubleClick','relayout','restyle','redraw','selected','selecting','sliderChange',
8889
'sliderEnd','sliderStart','transitioning','transitionInterrupted','unhover'];
8990

@@ -98,6 +99,13 @@ export class PlotComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
9899
constfigure=this.createFigure();
99100
this.initialized.emit(figure);
100101
});
102+
103+
104+
if(this.plotly.debug&&this.click.observers.length>0){
105+
constmsg='DEPRECATED: Reconsider using `(plotly_click)` instead of `(click)` to avoid event conflict. '
106+
+'Please check https://github.com/plotly/angular-plotly.js#FAQ';
107+
console.error(msg);
108+
}
101109
}
102110

103111
ngOnDestroy(){
@@ -188,6 +196,11 @@ export class PlotComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
188196
plotlyInstance.on(eventName,(data:any)=>(this[name]asEventEmitter<void>).emit(data));
189197
});
190198

199+
plotlyInstance.on('plotly_click',(data:any)=>{
200+
this.click.emit(data);
201+
this.plotly_click.emit(data);
202+
});
203+
191204
this.updateWindowResizeHandler();
192205
},err=>{
193206
console.error('Error while plotting:',err);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{Injectable}from'@angular/core';
22
import{Plotly}from'./plotly.interface';
3+
import{environment}from'../../environments/environment';
34

45
typePlotlyName='Plotly'|'ViaCDN'|'ViaWindow';
56

@@ -40,6 +41,10 @@ export class PlotlyService {
4041
}
4142
}
4243

44+
publicgetdebug():boolean{
45+
returnenvironment.production===false;
46+
}
47+
4348
publicgetInstanceByDivId(id:string):Plotly.PlotlyHTMLElement|undefined{
4449
for(constinstanceofPlotlyService.instances){
4550
if(instance&&instance.id===id){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp