示例#1
0
def test_ImageURL():
    glyph = ImageURL()
    assert glyph.url == "url"
    assert glyph.x == "x"
    assert glyph.y == "y"
    assert glyph.w == "w"
    assert glyph.h == "h"
    assert glyph.angle == "angle"
    assert glyph.dilate == False
    assert glyph.anchor == Anchor.top_left
    yield check_props, glyph, [
        "url", "x", "y", "w", "h", "angle", "dilate", "anchor"
    ]
示例#2
0
        y1=np.linspace(0, 150, N),
        w1=np.linspace(10, 50, N),
        h1=np.linspace(10, 50, N),
        x2=np.linspace(-50, 150, N),
        y2=np.linspace(0, 200, N),
    ))

xdr = Range1d(start=-100, end=200)
ydr = Range1d(start=-100, end=200)

plot = Plot(title="ImageURL", x_range=xdr, y_range=ydr)

image1 = ImageURL(url="url",
                  x="x1",
                  y="y1",
                  w="w1",
                  h="h1",
                  angle=0.0,
                  anchor="center")
plot.add_glyph(source, image1)

image2 = ImageURL(url="url",
                  x="x2",
                  y="y2",
                  w=20,
                  h=20,
                  angle=0.0,
                  anchor="top_left")
plot.add_glyph(source, image2)

image3 = ImageURL(url=dict(value=url),
示例#3
0
                 text="text",
                 angle="angle",
                 text_align="center",
                 text_baseline="middle")
    plot.add_glyph(text_source, glyph)


def to_base64(png):
    return "data:image/png;base64," + base64.b64encode(png).decode("utf-8")


urls = [to_base64(icons.get(browser, b"")) for browser in browsers]
x, y = polar_to_cartesian(1.7, start_angles, end_angles)

icons_source = ColumnDataSource(dict(urls=urls, x=x, y=y))
glyph = ImageURL(url="urls", x="x", y="y", angle=0.0, anchor="center")
plot.add_glyph(icons_source, glyph)

text = ["%.02f%%" % value for value in selected.Share]
x, y = polar_to_cartesian(0.7, start_angles, end_angles)

text_source = ColumnDataSource(dict(text=text, x=x, y=y))
glyph = Text(x="x",
             y="y",
             text="text",
             angle=0,
             text_align="center",
             text_baseline="middle")
plot.add_glyph(text_source, glyph)

doc = Document()