Exemplo n.º 1
0
class TestAnnularWedge(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import AnnularWedge
        self.test_annular_wedge = AnnularWedge()

    def test_expected_properties(self):
        expected_properties = set(['x','y','inner_radius','outer_radius','start_angle','end_angle','direction'])
        actual_properties = get_prop_set(type(self.test_annular_wedge))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_annular_wedge.__view_model__,'annular_wedge')
        self.assertEqual(self.test_annular_wedge.x,'x')
        self.assertEqual(self.test_annular_wedge.y,'y')
        self.assertEqual(self.test_annular_wedge.inner_radius, None)
        self.assertEqual(self.test_annular_wedge.outer_radius,None)
        self.assertEqual(self.test_annular_wedge.start_angle,'start_angle')
        self.assertEqual(self.test_annular_wedge.end_angle,'end_angle')

        self.assertEqual(self.test_annular_wedge.direction,'clock')
        self.test_annular_wedge.direction = 'anticlock'

    def test_to_glyphspec(self):
        self.assertEqual(self.test_annular_wedge.to_glyphspec(),{'line_color': {'value': 'black'}, 'fill_color': {'value': 'gray'}, 'start_angle': {'units': 'data', 'field': 'start_angle'}, 'end_angle': {'units': 'data', 'field': 'end_angle'}, 'outer_radius': {'units': 'data', 'field': None}, 'y': {'units': 'data', 'field': 'y'}, 'x': {'units': 'data', 'field': 'x'}, 'type': 'annular_wedge', 'inner_radius': {'units': 'data', 'field': None}})
        self.test_annular_wedge.x = 50
        self.test_annular_wedge.y = 100
        self.test_annular_wedge.inner_radius = 50
        self.test_annular_wedge.outer_radius = 51
        self.test_annular_wedge.start_angle = 91 
        self.test_annular_wedge.end_angle = 92
        self.test_annular_wedge.direction = 'anticlock'
        self.assertEqual(self.test_annular_wedge.to_glyphspec(), {'line_color': {'value': 'black'}, 'direction': 'anticlock', 'inner_radius': {'units': 'data', 'value': 50}, 'start_angle': {'units': 'data', 'value': 91}, 'end_angle': {'units': 'data', 'value': 92}, 'outer_radius': {'units': 'data', 'value': 51}, 'y': {'units': 'data', 'value': 100}, 'x': {'units': 'data', 'value': 50}, 'type': 'annular_wedge', 'fill_color': {'value': 'gray'}})
Exemplo n.º 2
0
class TestAnnularWedge(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import AnnularWedge

        self.test_annular_wedge = AnnularWedge()

    def test_expected_properties(self):
        expected_properties = set(["x", "y", "inner_radius", "outer_radius", "start_angle", "end_angle", "direction"])
        actual_properties = get_prop_set(type(self.test_annular_wedge))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_annular_wedge.__view_model__, "annular_wedge")
        self.assertEqual(self.test_annular_wedge.x, "x")
        self.assertEqual(self.test_annular_wedge.y, "y")
        self.assertEqual(self.test_annular_wedge.inner_radius, None)
        self.assertEqual(self.test_annular_wedge.outer_radius, None)
        self.assertEqual(self.test_annular_wedge.start_angle, "start_angle")
        self.assertEqual(self.test_annular_wedge.end_angle, "end_angle")

        self.assertEqual(self.test_annular_wedge.direction, "clock")
        self.test_annular_wedge.direction = "anticlock"

    def test_to_glyphspec(self):
        expected = dict(GENERIC_GLYPH_DICT)
        expected["type"] = "annular_wedge"
        expected.update(
            {
                "start_angle": {"units": "data", "field": "start_angle"},
                "end_angle": {"units": "data", "field": "end_angle"},
                "outer_radius": {"units": "data", "field": None},
                "inner_radius": {"units": "data", "field": None},
            }
        )
        self.assertEqual(self.test_annular_wedge.to_glyphspec(), expected)
        self.test_annular_wedge.x = 50
        self.test_annular_wedge.y = 100
        self.test_annular_wedge.inner_radius = 50
        self.test_annular_wedge.outer_radius = 51
        self.test_annular_wedge.start_angle = 91
        self.test_annular_wedge.end_angle = 92
        self.test_annular_wedge.direction = "anticlock"
        expected.update(
            {
                "x": {"units": "data", "value": 50},
                "y": {"units": "data", "value": 100},
                "start_angle": {"units": "data", "value": 91},
                "end_angle": {"units": "data", "value": 92},
                "outer_radius": {"units": "data", "value": 51},
                "inner_radius": {"units": "data", "value": 50},
                "direction": "anticlock",
            }
        )
        self.assertEqual(self.test_annular_wedge.to_glyphspec(), expected)
Exemplo n.º 3
0
class TestAnnularWedge(unittest.TestCase):

    def setUp(self):
        from bokeh.glyphs import AnnularWedge
        self.test_annular_wedge = AnnularWedge()

    def test_expected_properties(self):
        expected_properties = set(['x', 'y', 'inner_radius', 'outer_radius', 'start_angle', 'end_angle', 'direction'])
        actual_properties = get_prop_set(type(self.test_annular_wedge))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_annular_wedge.__view_model__, 'annular_wedge')
        self.assertEqual(self.test_annular_wedge.x, 'x')
        self.assertEqual(self.test_annular_wedge.y, 'y')
        self.assertEqual(self.test_annular_wedge.inner_radius, None)
        self.assertEqual(self.test_annular_wedge.outer_radius, None)
        self.assertEqual(self.test_annular_wedge.start_angle, 'start_angle')
        self.assertEqual(self.test_annular_wedge.end_angle, 'end_angle')

        self.assertEqual(self.test_annular_wedge.direction, 'clock')
        self.test_annular_wedge.direction = 'anticlock'

    def test_to_glyphspec(self):
        expected = dict(GENERIC_GLYPH_DICT)
        expected['type'] = 'annular_wedge'
        expected.update({
            'start_angle':  {'units': 'data', 'field': 'start_angle'},
            'end_angle':    {'units': 'data', 'field': 'end_angle'},
            'outer_radius': {},
            'inner_radius': {},
        })
        self.assertEqual(self.test_annular_wedge.to_glyphspec(), expected)
        self.test_annular_wedge.x = 50
        self.test_annular_wedge.y = 100
        self.test_annular_wedge.inner_radius = 50
        self.test_annular_wedge.outer_radius = 51
        self.test_annular_wedge.start_angle = 91
        self.test_annular_wedge.end_angle = 92
        self.test_annular_wedge.direction = 'anticlock'
        expected.update({
            'x':            {'units': 'data', 'value': 50},
            'y':            {'units': 'data', 'value': 100},
            'start_angle':  {'units': 'data', 'value': 91},
            'end_angle':    {'units': 'data', 'value': 92},
            'outer_radius': {'units': 'data', 'value': 51},
            'inner_radius': {'units': 'data', 'value': 50},
            'direction':    'anticlock',
        })
        self.assertEqual(self.test_annular_wedge.to_glyphspec(), expected)
Exemplo n.º 4
0
def test_AnnularWedge():
    glyph = AnnularWedge()
    assert glyph.x == "x"
    assert glyph.y == "y"
    assert glyph.inner_radius == None
    assert glyph.outer_radius == None
    assert glyph.start_angle == "start_angle"
    assert glyph.end_angle == "end_angle"
    assert glyph.direction == "clock"
    yield check_fill, glyph
    yield check_line, glyph
    yield check_props, glyph, [
        "x", "y", "inner_radius", "outer_radius", "start_angle", "end_angle",
        "direction"
    ], FILL, LINE
Exemplo n.º 5
0
 def setUp(self):
     from bokeh.glyphs import AnnularWedge
     self.test_annular_wedge = AnnularWedge()
Exemplo n.º 6
0
    ))

xdr = DataRange1d(sources=[source.columns("x")])
ydr = DataRange1d(sources=[source.columns("y")])


def screen(value):
    return dict(value=value, units="screen")


glyphs = [
    ("annular_wedge",
     AnnularWedge(x="x",
                  y="y",
                  inner_radius=screen(10),
                  outer_radius=screen(20),
                  start_angle=0.6,
                  end_angle=4.1,
                  fill_color="#8888ee")),
    ("annulus",
     Annulus(x="x",
             y="y",
             inner_radius=screen(10),
             outer_radius=screen(20),
             fill_color="#7FC97F")),
    ("arc",
     Arc(x="x",
         y="y",
         radius=screen(20),
         start_angle=0.6,
         end_angle=4.1,
Exemplo n.º 7
0
 def setUp(self):
     from bokeh.glyphs import AnnularWedge
     self.test_annular_wedge = AnnularWedge()
Exemplo n.º 8
0
class TestAnnularWedge(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import AnnularWedge
        self.test_annular_wedge = AnnularWedge()

    def test_expected_properties(self):
        expected_properties = set([
            'x', 'y', 'inner_radius', 'outer_radius', 'start_angle',
            'end_angle', 'direction'
        ])
        actual_properties = get_prop_set(type(self.test_annular_wedge))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_annular_wedge.__view_model__,
                         'annular_wedge')
        self.assertEqual(self.test_annular_wedge.x, 'x')
        self.assertEqual(self.test_annular_wedge.y, 'y')
        self.assertEqual(self.test_annular_wedge.inner_radius, None)
        self.assertEqual(self.test_annular_wedge.outer_radius, None)
        self.assertEqual(self.test_annular_wedge.start_angle, 'start_angle')
        self.assertEqual(self.test_annular_wedge.end_angle, 'end_angle')

        self.assertEqual(self.test_annular_wedge.direction, 'clock')
        self.test_annular_wedge.direction = 'anticlock'

    def test_to_glyphspec(self):
        expected = dict(GENERIC_GLYPH_DICT)
        expected['type'] = 'annular_wedge'
        expected.update({
            'start_angle': {
                'units': 'data',
                'field': 'start_angle'
            },
            'end_angle': {
                'units': 'data',
                'field': 'end_angle'
            },
            'outer_radius': {
                'units': 'data',
                'field': None
            },
            'inner_radius': {
                'units': 'data',
                'field': None
            },
        })
        self.assertEqual(self.test_annular_wedge.to_glyphspec(), expected)
        self.test_annular_wedge.x = 50
        self.test_annular_wedge.y = 100
        self.test_annular_wedge.inner_radius = 50
        self.test_annular_wedge.outer_radius = 51
        self.test_annular_wedge.start_angle = 91
        self.test_annular_wedge.end_angle = 92
        self.test_annular_wedge.direction = 'anticlock'
        expected.update({
            'x': {
                'units': 'data',
                'value': 50
            },
            'y': {
                'units': 'data',
                'value': 100
            },
            'start_angle': {
                'units': 'data',
                'value': 91
            },
            'end_angle': {
                'units': 'data',
                'value': 92
            },
            'outer_radius': {
                'units': 'data',
                'value': 51
            },
            'inner_radius': {
                'units': 'data',
                'value': 50
            },
            'direction': 'anticlock',
        })
        self.assertEqual(self.test_annular_wedge.to_glyphspec(), expected)
Exemplo n.º 9
0
    end = angles.tolist() + [end_angle]
    start = [start_angle] + end[:-1]
    base_color = colors[browser]
    fill = [base_color.lighten(i * 0.05) for i in range(len(versions) + 1)]
    text = [
        number if share >= 1 else ""
        for number, share in zip(versions.VersionNumber, versions.Share)
    ]
    x, y = polar_to_cartesian(1.25, start, end)

    source = ColumnDataSource(dict(start=start, end=end, fill=fill))
    glyph = AnnularWedge(x=0,
                         y=0,
                         inner_radius=1,
                         outer_radius=1.5,
                         start_angle="start",
                         end_angle="end",
                         line_color="white",
                         line_width=2,
                         fill_color="fill")
    plot.add_glyph(source, glyph)

    text_angle = [(start[i] + end[i]) / 2 for i in range(len(start))]
    text_angle = [
        angle + pi if pi / 2 < angle < 3 * pi / 2 else angle
        for angle in text_angle
    ]

    if first and text:
        text.insert(0, '(version)')
        offset = pi / 48