Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: DataBox Overlay Causing Component to Disappear #456

Closed
skailasa opened this issue Jun 25, 2019 · 0 comments
Closed

BUG: DataBox Overlay Causing Component to Disappear #456

skailasa opened this issue Jun 25, 2019 · 0 comments

Comments

@skailasa
Copy link
Contributor

skailasa commented Jun 25, 2019

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

@skailasa skailasa changed the title DataBox Overlay BUG: DataBox Overlay Disappearing Jun 25, 2019
@skailasa skailasa changed the title BUG: DataBox Overlay Disappearing BUG: DataBox Overlay Causing Component to Disappear Jun 25, 2019
jvkersch pushed a commit that referenced this issue Jun 30, 2019
BUG: Fix DataBox resizing bug (#456)
@skailasa skailasa closed this as completed Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant