bokeh.io.export.get_svgs

Here are the examples of the python api bokeh.io.export.get_svgs taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

3 Source : test_export.py
with MIT License
from rthorst

def test_get_svgs_no_svg_present():
    layout = Plot(x_range=Range1d(), y_range=Range1d(),
              plot_height=20, plot_width=20, toolbar_location=None)

    svgs = bie.get_svgs(layout)
    assert svgs == []

@pytest.mark.unit

0 Source : test_export.py
with MIT License
from rthorst

def test_get_svgs_with_svg_present(webdriver):

    def fix_ids(svg):
        svg = re.sub(r'id="\w{12}"', 'id="X"', svg)
        svg = re.sub(r'url\(#\w{12}\)', 'url(#X)', svg)
        return svg

    layout = Plot(x_range=Range1d(), y_range=Range1d(),
                  plot_height=20, plot_width=20, toolbar_location=None,
                  outline_line_color=None, border_fill_color=None,
                  background_fill_color="red", output_backend="svg")

    svg0 = fix_ids(bie.get_svgs(layout, driver=webdriver)[0])
    svg1 = fix_ids(bie.get_svgs(layout, driver=webdriver)[0])

    svg2 = (
        '  <  svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" '
        'width="20" height="20" style="width: 20px; height: 20px;">'
        ' < defs/>'
        ' < g>'
            ' < g transform="scale(1,1) translate(0.5,0.5)">'
                ' < rect fill="#FFFFFF" stroke="none" x="0" y="0" width="20" height="20"/>'
                ' < rect fill="red" stroke="none" x="5" y="5" width="10" height="10"/>'
                ' < g/>'
            ' < /g>'
        ' < /g>'
        ' < /svg>'
    )

    assert svg0 == svg2
    assert svg1 == svg2

def test_get_layout_html_resets_plot_dims():

0 Source : bokeh_figures.py
with MIT License
from SolarArbiter

def output_svg(fig, driver=None):
    """
    Generates an SVG from the Bokeh figure. Errors in the
    process are logged and an SVG with error text is returned.

    Parameters
    ----------
    fig : bokeh.plotting.Figure
    driver : selenium.webdriver.remote.webdriver.WebDriver, default None
        Web driver to use to render SVG figures. With bokeh  <  2.0 this
        defaults to trying to use phantomjs.

    Returns
    -------
    svg : str
    """
    fig.output_backend = 'svg'
    try:
        svg = get_svgs(fig, driver=driver)[0]
    except Exception:
        logger.error('Could not generate SVG for figure %s',
                     getattr(fig, 'name', 'unnamed'))
        svg = (
            ' < svg width="100%" height="100%">'
            ' < text x="50" y="50" class="alert alert-error">'
            'Unable to generate SVG plot.'
            ' < /text>'
            ' < /svg>')
    return svg


def raw_report_plots(report, metrics):