def test_dataspec_value_in_json(self) -> None: from bokeh.models import AnnularWedge obj = AnnularWedge() obj.start_angle = 60 json = obj.to_json(include_defaults=True) assert 'start_angle' in json assert 'start_angle_units' not in json assert dict(units='rad', value=60) == json['start_angle']
def test_no_units_in_json(self) -> None: from bokeh.models import AnnularWedge obj = AnnularWedge() json = obj.to_json(include_defaults=True) assert 'start_angle' in json assert 'start_angle_units' not in json assert 'outer_radius' in json assert 'outer_radius_units' not in json
def test_dataspec_field_in_json(self) -> None: from bokeh.models import AnnularWedge obj = AnnularWedge() obj.start_angle = "fieldname" json = obj.to_json(include_defaults=True) assert 'start_angle' in json assert 'start_angle_units' not in json assert dict(units='rad', field='fieldname') == json['start_angle']
def test_no_units_in_json(self): from bokeh.models import AnnularWedge obj = AnnularWedge() json = obj.to_json(include_defaults=True) self.assertTrue('start_angle' in json) self.assertTrue('start_angle_units' not in json) self.assertTrue('outer_radius' in json) self.assertTrue('outer_radius_units' not in json)
def test_dataspec_value_in_json(self): from bokeh.models import AnnularWedge obj = AnnularWedge() obj.start_angle = 60 json = obj.to_json(include_defaults=True) self.assertTrue('start_angle' in json) self.assertTrue('start_angle_units' not in json) self.assertDictEqual(dict(units='rad', value=60), json['start_angle'])
def test_dataspec_field_in_json(self): from bokeh.models import AnnularWedge obj = AnnularWedge() obj.start_angle = "fieldname" json = obj.to_json(include_defaults=True) assert 'start_angle' in json assert 'start_angle_units' not in json assert dict(units='rad', field='fieldname') == json['start_angle']
def test_dataspec_value_in_json(self): from bokeh.models import AnnularWedge obj = AnnularWedge() obj.start_angle = 60 json = obj.to_json(include_defaults=True) self.assertTrue('start_angle' in json) self.assertTrue('start_angle_units' not in json) self.assertDictEqual(dict(units='rad', value=60), json['start_angle'])
def test_dataspec_field_in_json(self): from bokeh.models import AnnularWedge obj = AnnularWedge() obj.start_angle = "fieldname" json = obj.to_json(include_defaults=True) self.assertTrue("start_angle" in json) self.assertTrue("start_angle_units" not in json) self.assertDictEqual(dict(units="rad", field="fieldname"), json["start_angle"])
base_color.lighten(i * 0.05).to_hex() for i in range(len(versions) + 1) ] # extra empty string accounts for all versions with share < 0.5 together 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 ] text_source = ColumnDataSource(dict(text=text, x=x, y=y, angle=text_angle)) glyph = Text(x="x", y="y",
ym01=y - 0.1, )) print() 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,
from bokeh.io import curdoc, show from bokeh.models import AnnularWedge, ColumnDataSource, Grid, LinearAxis, Plot N = 9 x = np.linspace(-2, 2, N) y = x**2 r = x/12.0+0.4 source = ColumnDataSource(dict(x=x, y=y, r=r)) plot = Plot( title=None, width=300, height=300, min_border=0, toolbar_location=None) glyph = AnnularWedge(x="x", y="y", inner_radius=.2, outer_radius="r", start_angle=0.6, end_angle=4.1, fill_color="#8888ee") plot.add_glyph(source, glyph) xaxis = LinearAxis() plot.add_layout(xaxis, 'below') yaxis = LinearAxis() plot.add_layout(yaxis, 'left') plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker)) plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker)) curdoc().add_root(plot) show(plot)