MCPcopy Create free account
hub / github.com/plotly/plotly.py / VegaHTML

Class VegaHTML

plotly/matplotlylib/mplexporter/renderers/vega_renderer.py:103–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102
103class VegaHTML(object):
104 def __init__(self, renderer):
105 self.specification = dict(
106 width=renderer.figwidth,
107 height=renderer.figheight,
108 data=renderer.data,
109 scales=renderer.scales,
110 axes=renderer.axes,
111 marks=renderer.marks,
112 )
113
114 def html(self):
115 """Build the HTML representation for IPython."""
116 id = random.randint(0, 2**16)
117 html = '<div id="vis%d"></div>' % id
118 html += "<script>\n"
119 html += VEGA_TEMPLATE % (json.dumps(self.specification), id)
120 html += "</script>\n"
121 return html
122
123 def _repr_html_(self):
124 return self.html()
125
126
127def fig_to_vega(fig, notebook=False):

Callers 1

fig_to_vegaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected