def static_plot(static_plot_type):
    (data_setting, config) = load_forms(static_plot_type)
    selected_frame_id = load_selected_frame_id(static_plot_type)
    if selected_frame_id is None:
        frame = gen_empty_data_frame_from_data_setting(data_setting)
    else:
        frame = frame_pool.get_data(selected_frame_id, data_setting)
    fig = drawers.draw(static_plot_type, frame, data_setting, config)
    show_path = os.path.join(render_api.root_path, 'saved_plots/',
                             static_plot_type + '_show.svg')
    download_path = os.path.join(render_api.root_path, 'saved_plots/',
                                 static_plot_type + '_download.eps')
    fig.savefig(show_path, format='svg', dpi=600)
    fig.savefig(download_path, format='eps', dpi=600)
    plot_div = mpld3.fig_to_html(fig)
    fig.clear()
    '''
    html = flask.render_template(
        'rendering/static_plot.html',
        plot_div=plot_div,
    )
    return encode_utf8(html)
    '''
    svg = open(show_path).read()
    response = flask.make_response(svg)
    response.content_type = 'image/svg+xml'
    return response
def interactive_query_cache(interactive_plot_type):
    (data_setting, config,
     interaction_config) = load_forms(interactive_plot_type)
    return flask.jsonify(
        dict(selected_frame_id=io.load('selected_frame_id'),
             data_setting=data_setting,
             config=config,
             interation_config=interaction_config))
def static_page(static_plot_type):
    if not check_plot_type(static_plot_type):
        return "Unsupported plot type"
    global frame_pool
    frame_pool = FramePool()
    initialize_forms(static_plot_type)
    try:
        (data_setting, config) = load_forms(static_plot_type)
    except ValueError:
        return "Requested plot is located under /render/interactive/"
    html = flask.render_template(
        'rendering/static_page.html',
        plot_type=static_plot_type,
        data_setting=data_setting,
        config=config,
    )
    return html
def interactive_plot(interactive_plot_type):
    (data_setting, config,
     interaction_config) = load_forms(interactive_plot_type)
    selected_frame_id = load_selected_frame_id(interactive_plot_type)
    if selected_frame_id is None:
        frame = gen_empty_data_frame_from_data_setting(data_setting)
    else:
        frame = frame_pool.get_data(selected_frame_id, data_setting)
    js_resources = bokeh.resources.INLINE.render_js()
    css_resources = bokeh.resources.INLINE.render_css()
    layout = drawers.draw(interactive_plot_type, frame, data_setting, config,
                          interaction_config)
    script, div = bokeh.embed.components(layout)
    html = flask.render_template(
        'rendering/interactive_plot.html',
        plot_script=script,
        plot_div=div,
        js_resources=js_resources,
        css_resources=css_resources,
    )
    return encode_utf8(html)
def static_query_cache(static_plot_type):
    (data_setting, config) = load_forms(static_plot_type)
    return flask.jsonify(
        dict(selected_frame_id=io.load('selected_frame_id'),
             data_setting=data_setting,
             config=config))
def static_get_data_setting(static_plot_type):
    data_setting = load_forms(static_plot_type)[0]
    return flask.jsonify(result=data_setting)
def interactive_get_data_setting(interactive_plot_type):
    data_setting = load_forms(interactive_plot_type)[0]
    return flask.jsonify(result=data_setting)