Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive charts: result.results[0].chart is undefined when running a bar chart script #50

Open
dev-habib-nuhu opened this issue Dec 8, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dev-habib-nuhu
Copy link

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
Copy link

linear bot commented Dec 8, 2024

@mlejva mlejva added the bug Something isn't working label Dec 8, 2024
@dev-habib-nuhu 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants