@@ -15,6 +15,13 @@ define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
1515 var pdata = [ ] ;
1616 var annotations = [ ] ;
1717
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+
1825 Object . keys ( data ) . map ( function ( key ) {
1926 if ( data [ key ] . annotations . length ) {
2027 data [ key ] . annotations . map ( function ( ann ) {
@@ -34,12 +41,17 @@ define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
3441 pdata . push ( {
3542 x : data [ key ] . data . map ( function ( xy ) { return xy [ 0 ] ; } ) ,
3643 y : data [ key ] . data . map ( function ( xy ) { return xy [ 1 ] ; } ) ,
37- mode : ' lines',
44+ mode : ! data [ key ] . annotations . length ? 'lines' : 'markers+ lines',
3845 type : 'scatter' ,
3946 name : key ,
4047 marker : {
4148 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+ } ) ,
4355 /*
4456 color: "rgb(164, 194, 244)",
4557 line: {
@@ -119,10 +131,8 @@ define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
119131
120132 myPlot . on ( 'plotly_click' , function ( data ) {
121133 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 ) ) ;
126136 if ( foundAnnotations . length ) {
127137 foundAnnotations . map ( ( foundAnn ) => {
128138 var newAnnotation = {
0 commit comments