MCPcopy Create free account
hub / github.com/alceal/plotlars / render_html_from_json

Function render_html_from_json

crates/plotlars-plotly/src/render/mod.rs:33–48  ·  view source on GitHub ↗

Render plot JSON (possibly with overrides) to a standalone HTML document.

(plot_json: &str)

Source from the content-addressed store, hash-verified

31
32/// Render plot JSON (possibly with overrides) to a standalone HTML document.
33pub(crate) fn render_html_from_json(plot_json: &str) -> String {
34 format!(
35 r#"<html>
36<head><meta charset="utf-8" /></head>
37<body>
38<div id="plotly-div" style="height:100%; width:100%;"></div>
39<script src="https://cdn.plot.ly/plotly-3.0.1.min.js"></script>
40<script type="text/javascript">
41 var plotData = {plot_json};
42 Plotly.newPlot("plotly-div", plotData.traces, plotData.layout, {{}});
43</script>
44</body>
45</html>"#,
46 plot_json = plot_json
47 )
48}
49
50/// Render plot JSON to an inline HTML snippet.
51pub(crate) fn render_inline_html_from_json(plot_json: &str, div_id: &str) -> String {

Callers 3

plotMethod · 0.85
write_htmlMethod · 0.85
to_htmlMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected