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

Function render_inline_html_from_json

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

Render plot JSON to an inline HTML snippet.

(plot_json: &str, div_id: &str)

Source from the content-addressed store, hash-verified

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 {
52 format!(
53 r#"<div id="{div_id}" class="plotly-graph-div" style="height:100%; width:100%;"></div>
54<script type="text/javascript">
55 var plotData = {plot_json};
56 Plotly.newPlot("{div_id}", plotData.traces, plotData.layout, {{}});
57</script>"#,
58 div_id = div_id,
59 plot_json = plot_json
60 )
61}
62
63pub(crate) fn ir_to_json(data: &impl Plot) -> Result<String, serde_json::Error> {
64 let (layout, layout_overrides) = crate::converters::layout::convert_layout_ir(data.ir_layout());

Callers 1

to_inline_htmlMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected