@@ -15,6 +15,13 @@ define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
15
15
var pdata = [ ] ;
16
16
var annotations = [ ] ;
17
17
18
+ var findAnnotations = function ( x , y ) {
19
+ var foundAnnotations = annotations . filter ( function ( ann ) {
20
+ return ann . x == x && ann . y == y ;
21
+ } ) ;
22
+ return foundAnnotations ;
23
+ } ;
24
+
18
25
Object . keys ( data ) . map ( function ( key ) {
19
26
if ( data [ key ] . annotations . length ) {
20
27
data [ key ] . annotations . map ( function ( ann ) {
@@ -34,12 +41,17 @@ define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
34
41
pdata . push ( {
35
42
x : data [ key ] . data . map ( function ( xy ) { return xy [ 0 ] ; } ) ,
36
43
y : data [ key ] . data . map ( function ( xy ) { return xy [ 1 ] ; } ) ,
37
- mode : ' lines',
44
+ mode : ! data [ key ] . annotations . length ? 'lines' : 'markers+ lines',
38
45
type : 'scatter' ,
39
46
name : key ,
40
47
marker : {
41
48
maxdisplayed : 1000 ,
42
- size : 12 ,
49
+ size : ! data [ key ] . annotations . length ? [ ] : data [ key ] . data . map ( function ( xy ) {
50
+ if ( findAnnotations ( xy [ 0 ] , xy [ 1 ] ) . length > 0 )
51
+ return 15 ;
52
+ else
53
+ return 1 ;
54
+ } ) ,
43
55
/*
44
56
color: "rgb(164, 194, 244)",
45
57
line: {
@@ -119,10 +131,8 @@ define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
119
131
120
132
myPlot . on ( 'plotly_click' , function ( data ) {
121
133
var point = data . points [ 0 ] ;
122
- var foundAnnotations = annotations . filter ( function ( ann ) {
123
- return ann . x == point . xaxis . d2l ( point . x ) &&
124
- ann . y == point . yaxis . d2l ( point . y ) ;
125
- } ) ;
134
+ var foundAnnotations = findAnnotations ( point . xaxis . d2l ( point . x ) ,
135
+ point . yaxis . d2l ( point . y ) ) ;
126
136
if ( foundAnnotations . length ) {
127
137
foundAnnotations . map ( ( foundAnn ) => {
128
138
var newAnnotation = {
0 commit comments