Skip to content

Commit

Permalink
Merge pull request #282 from WarrenWeckesser/bug-label-arrow-not-visible
Browse files Browse the repository at this point in the history
BUG: Fix undefined variable in DataLabel when arrow_visible is False.
  • Loading branch information
corranwebster committed Nov 13, 2015
2 parents 2fc5251 + 6227202 commit fe9f02c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chaco/data_label.py
Expand Up @@ -405,8 +405,8 @@ def _render_bubble(self, component, gc, view_bounds=None, mode='normal'):
by = y2
else:
by = y
arrow_len = sqrt((px - bx)**2 + (py - by)**2)

arrow_len = sqrt((px - bx) ** 2 + (py - by) ** 2)
arrow_visible = (self.arrow_visible and
(arrow_len >= self.arrow_min_length))

Expand Down
30 changes: 30 additions & 0 deletions chaco/tests/test_data_label.py
@@ -0,0 +1,30 @@
import unittest
from chaco.api import create_scatter_plot, PlotGraphicsContext, DataLabel


class DataLabelTestCase(unittest.TestCase):

def test_data_label_arrow_not_visible(self):
# Regression test for https://github.com/enthought/chaco/issues/281
# Before the problem was fixed, this test (specifically, using
# arrow_visible=False in the DataLabel constructor) would raise an
# exception because of an undefined reference.
size = (50, 50)
plot = create_scatter_plot(data=[range(10), range(10)])
label = DataLabel(component=plot,
data_point=(4, 4),
marker_color="red",
marker_size=3,
label_position=(20, 50),
label_style='bubble',
label_text="Something interesting",
label_format="at x=%(x).2f, y=%(y).2f",
arrow_visible=False)
plot.overlays.append(label)
plot.outer_bounds = list(size)
gc = PlotGraphicsContext(size)
gc.render_component(plot)


if __name__ == "__main__":
unittest.main()

0 comments on commit fe9f02c

Please sign in to comment.