Пример #1
0
def render_graph_container_html(graph_recipe, graph_data_range,
                                graph_render_options):
    graph_render_options = artwork.add_default_render_options(
        graph_render_options)

    # Estimate size of graph. This will not be the exact size of the graph, because
    # this does calculate the size of the canvas area and does not take e.g. the legend
    # into account. We would need the graph_artwork to calculate that, but this is something
    # we don't have in this early stage.
    size = graph_render_options["size"]
    graph_width = size[0] * html_size_per_ex
    graph_height = size[1] * html_size_per_ex

    content = html.render_div("", class_="title") \
            + html.render_div("",
                class_="content",
                style="width:%dpx;height:%dpx" % (graph_width, graph_height))

    output = html.render_div(html.render_div(content, class_=["graph", "loading_graph"]),
                             class_="graph_load_container") \

    output += html.render_javascript(
        "cmk.graphs.load_graph_content(%s, %s, %s)" % (
            json.dumps(graph_recipe),
            json.dumps(graph_data_range),
            json.dumps(graph_render_options),
        ))

    if "cmk.graphs.register_delayed_graph_listener" not in html.final_javascript_code:
        html.final_javascript("cmk.graphs.register_delayed_graph_listener()")

    return output
Пример #2
0
def render_graph_html(graph_artwork, graph_data_range, graph_render_options):
    graph_render_options = artwork.add_default_render_options(graph_render_options)

    html_code = render_graph_html_content(graph_artwork, graph_data_range, graph_render_options)

    return html.render_javascript(
        'cmk.graphs.create_graph(%s, %s, %s, %s);' %
        (json.dumps("%s" % html_code), json.dumps(graph_artwork), json.dumps(graph_render_options),
         json.dumps(graph_ajax_context(graph_artwork, graph_data_range, graph_render_options))))
Пример #3
0
def render_graph_html(graph_artwork, graph_data_range,
                      graph_render_options) -> HTML:
    graph_render_options = artwork.add_default_render_options(
        graph_render_options)

    with output_funnel.plugged():
        _show_graph_html_content(graph_artwork, graph_data_range,
                                 graph_render_options)
        html_code = HTML(output_funnel.drain())

    return html.render_javascript(
        'cmk.graphs.create_graph(%s, %s, %s, %s);' %
        (json.dumps(html_code), json.dumps(graph_artwork),
         json.dumps(graph_render_options),
         json.dumps(
             graph_ajax_context(graph_artwork, graph_data_range,
                                graph_render_options))))