You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue while using the @e2b/code-interpreter package to run a Python script for generating a bar chart. The chart property in the result.results[0] object is undefined, even though the script executes successfully. only text and png is returned. Below is the code snippet I used:
import { Sandbox, BarChart } from '@e2b/code-interpreter'
const code = `
import matplotlib.pyplot as plt
# Prepare data
authors = ['Author A', 'Author B', 'Author C', 'Author D']
sales = [100, 200, 300, 400]
# Create and customize the bar chart
plt.figure(figsize=(10, 6))
plt.bar(authors, sales, label='Books Sold', color='blue')
plt.xlabel('Authors')
plt.ylabel('Number of Books Sold')
plt.title('Book Sales by Authors')
# Display the chart
plt.tight_layout()
plt.show()
`
const sandbox = await Sandbox.create()
const result = await sandbox.runCode(code)
const chart = result.results[0].chart as BarChart
console.log(chart) // chart is undefined
The text was updated successfully, but these errors were encountered:
dev-habib-nuhu
changed the title
result.results[0].chart is undefined when running a bar chart script
Interactive charts: result.results[0].chart is undefined when running a bar chart script
Dec 8, 2024
I encountered an issue while using the @e2b/code-interpreter package to run a Python script for generating a bar chart. The chart property in the
result.results[0]
object is undefined, even though the script executes successfully. only text and png is returned. Below is the code snippet I used:The text was updated successfully, but these errors were encountered: