File tree Expand file tree Collapse file tree
fastplotlib/graphics/selectors Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,10 +183,13 @@ def __init__(
183183 world_object .add (line_outer )
184184 world_object .add (line_inner )
185185
186- if axis == "x" :
187- offset = (parent .offset [0 ], 0 , 0 )
188- elif axis == "y" :
189- offset = (0 , parent .offset [1 ], 0 )
186+ if parent is None :
187+ offset = (0 , 0 , 0 )
188+ else :
189+ if axis == "x" :
190+ offset = (parent .offset [0 ], 0 , 0 )
191+ elif axis == "y" :
192+ offset = (0 , parent .offset [1 ], 0 )
190193
191194 # init base selector
192195 BaseSelector .__init__ (
Original file line number Diff line number Diff line change @@ -277,12 +277,15 @@ def __init__(
277277 outer_edges = (line0_outer , line1_outer )
278278 group .add (* edges , * outer_edges )
279279
280- # TODO: if parent offset changes, we should set the selector offset too, use offset evented property
281- # TODO: add check if parent is `None`, will throw error otherwise
282- if axis == "x" :
283- offset = (parent .offset [0 ], center + parent .offset [1 ], 0 )
284- elif axis == "y" :
285- offset = (center + parent .offset [1 ], parent .offset [1 ], 0 )
280+ if parent is None :
281+ offset = (0 , 0 , 0 )
282+ else :
283+ # TODO: if parent offset changes, we should set the selector offset too, use offset evented property
284+ # TODO: add check if parent is `None`, will throw error otherwise
285+ if axis == "x" :
286+ offset = (parent .offset [0 ], center + parent .offset [1 ], 0 )
287+ elif axis == "y" :
288+ offset = (center + parent .offset [1 ], parent .offset [1 ], 0 )
286289
287290 # set the initial bounds of the selector
288291 # compensate for any offset from the parent graphic
You can’t perform that action at this time.
0 commit comments