@@ -796,27 +796,7 @@ def get_figure(
796796 clickmode = "event+select" ,
797797 )
798798
799- default_red_dot = [
800- {
801- "type" : "scatter" ,
802- "mode" : "markers" ,
803- "x" : [0 ],
804- "y" : [0 ],
805- "marker" : {
806- "color" : MARKER_COLOR ,
807- "size" : MARKER_SIZE ,
808- "symbol" : MARKER_SHAPE ,
809- },
810- "name" : "click-marker" ,
811- "showlegend" : False ,
812- "customdata" : [[0 , 0 ]],
813- "hovertemplate" : (
814- "band: %{customdata[1]}<br>q-point: %{customdata[0]}<br>"
815- ),
816- }
817- ]
818-
819- figure = {"data" : bs_traces + dos_traces + default_red_dot , "layout" : layout }
799+ figure = {"data" : bs_traces + dos_traces , "layout" : layout }
820800
821801 legend = dict (
822802 x = 1.02 ,
@@ -851,37 +831,37 @@ def update_graph(bs, dos, nclick):
851831 dos = CompletePhononDos .from_dict (dos )
852832
853833 figure = self .get_figure (bs , dos )
854- if nclick and nclick .get ("points" ):
855- # remove marker if there is one
856- figure ["data" ] = [
857- t for t in figure ["data" ] if t .get ("name" ) != "click-marker"
858- ]
859834
860- x_click = nclick ["points" ][0 ]["x" ]
861- y_click = nclick ["points" ][0 ]["y" ]
835+ # remove marker if there is one
836+ figure ["data" ] = [
837+ t for t in figure ["data" ] if t .get ("name" ) != "click-marker"
838+ ]
862839
863- pt = nclick ["points" ][0 ]
864- qpoint , band_num = pt .get ("customdata" , [0 , 0 ])
840+ x_click = nclick ["points" ][0 ]["x" ] if nclick else 0
841+ y_click = nclick ["points" ][0 ]["y" ] if nclick else 0
842+ pt = nclick ["points" ][0 ] if nclick else {}
865843
866- figure ["data" ].append (
867- {
868- "type" : "scatter" ,
869- "mode" : "markers" ,
870- "x" : [x_click ],
871- "y" : [y_click ],
872- "marker" : {
873- "color" : MARKER_COLOR ,
874- "size" : MARKER_SIZE ,
875- "symbol" : MARKER_SHAPE ,
876- },
877- "name" : "click-marker" ,
878- "showlegend" : False ,
879- "customdata" : [[qpoint , band_num ]],
880- "hovertemplate" : (
881- "band: %{customdata[1]}<br>q-point: %{customdata[0]}<br>"
882- ),
883- }
884- )
844+ qpoint , band_num = pt .get ("customdata" , [0 , 0 ])
845+
846+ figure ["data" ].append (
847+ {
848+ "type" : "scatter" ,
849+ "mode" : "markers" ,
850+ "x" : [x_click ],
851+ "y" : [y_click ],
852+ "marker" : {
853+ "color" : MARKER_COLOR ,
854+ "size" : MARKER_SIZE ,
855+ "symbol" : MARKER_SHAPE ,
856+ },
857+ "name" : "click-marker" ,
858+ "showlegend" : False ,
859+ "customdata" : [[qpoint , band_num ]],
860+ "hovertemplate" : (
861+ "band: %{customdata[1]}<br>q-point: %{customdata[0]}<br>"
862+ ),
863+ }
864+ )
885865
886866 zone_scene = self .get_brillouin_zone_scene (bs )
887867
0 commit comments