コード例 #1
0
 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']
コード例 #2
0
 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
コード例 #3
0
 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']
コード例 #4
0
ファイル: test_objects.py プロジェクト: ghyde/bokeh
 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)
コード例 #5
0
ファイル: test_objects.py プロジェクト: ghyde/bokeh
 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'])
コード例 #6
0
ファイル: test_objects.py プロジェクト: HuntJSparra/bokeh
 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']
コード例 #7
0
 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'])
コード例 #8
0
ファイル: test_objects.py プロジェクト: quasiben/bokeh
    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"])
コード例 #9
0
        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",
コード例 #10
0
        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,
コード例 #11
0
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)