Open
Description
Describe the bug
HTML output from Python visualization libraries (Plotly/Bokeh) in the sandbox is fragmented into multiple objects, resulting in incomplete rendering. This issue appears specific to Python HTML-generating chart libraries, as the same charts created with R display correctly with complete HTML output.
To Reproduce
const code = `
import plotly.express as px
import pandas as pd
data = {
'Month': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
'Sales': [20, 35, 30, 40, 55, 60]
}
df = pd.DataFrame(data)
fig = px.line(df, x='Month', y='Sales', title='Monthly Sales')
fig.update_layout(
xaxis_title='Month',
yaxis_title='Sales ($1000s)',
template='plotly_white'
)
fig.show()
`
await sandbox.runCode(code, {
language: 'python',
onResult: async result => {
if ('html' in result && result.html) {
// Truncate the output for demo purposes
console.log('HTML Output: ', result.html.substring(0, 200))
}
})
Expected output: Complete HTML in a single object (as seen with R charts)
Actual output:
HTML Output: <script type="text/javascript"> window.PlotlyConfig = {MathJaxConfig: 'local'}; if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Confi
HTML Output: <div><div id="0bd7d700-2c9b-441c-84b4-084dce8b1bea" class="plotly-graph-div" style="height:525px; width:100%;"></div><script type="text/javascript">
Additional context:
The same visualization created with R in the sandbox produces a single complete HTML output without fragmentation.
"e2b": "^1.2.0-beta.0"
"@e2b/cli": "^1.3.2"
"@e2b/code-interpreter": "^1.2.0-beta.1"