Skip to content

BUG: DataBox Overlay Causing Component to Disappear #456

@skailasa

Description

@skailasa

Problem Description

Resizing component containing DataBox failing due to bug in position update. It causes the component to 'disappear'

This is due to the fact that when updating the position, the first element of the transpose of tmp is taken which is the wrong dimension, tmp is a (1,2) array.meaning that first element of its transpose is just a (1,1) array leading to an error when attempting to unpack these values into xs and ys in map_data

    # lines 144-152 in DataBox.py
    @on_trait_change('position,position_items')
    def _update_position(self):
        if self._updating:
            return
        tmp = self.component.map_data(self.position)
        if len(tmp.shape) == 2:
            tmp = tmp.T[0]
        self._data_position = tmp
        self.trait_property_changed("data_position", self._data_position)

Reproduction Steps:

# Create traitsui view, with a component containing a DataBox

class Demo(HasTraits):
  
  plot = Instance(Plot)

  def _plot_default(self):
  	data = ...
  	plot = Plot(data)

  	databox_overlay = DataBox(component=plot)
  	move_tool = MoveTool(component=databox_overlay)
  	databox_overlay.tools.append(move_tool)

  	plot.overlays.append(databox_overlay)


  view = View(
  Item('plot')
  )


if __name__ == "__main__":
  Demo().configure_traits()

Expected behavior:

No errors when resizing plot component with DataBox overlay

OS, Python version:
MacOS Python 3.60

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions