> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ns.rocks/llms.txt
> Use this file to discover all available pages before exploring further.

# Interactive charts

> Create Plotly and other rich notebook outputs from code interpreter runs.

Interactive libraries such as Plotly can emit HTML or JavaScript-backed notebook
outputs. For the most portable workflow, save interactive charts as HTML files
and download or serve them from the machine.

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
result = machine.run_code("""
import plotly.express as px

fig = px.line(x=[1, 2, 3], y=[1, 4, 9], title="Interactive chart")
fig.write_html("/workspace/chart.html")
fig.show()
""")

print(any(item.html or item.javascript for item in result.results))
```

Rich result objects (`item.html`, `item.javascript`) are SDK-only. Via the CLI
or HTTP API, write the chart to an HTML file (as above) and fetch it with `code
artifact download` or a filesystem read.

Read the generated HTML directly:

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
html = machine.files.read("/workspace/chart.html")
```

## Related

* [Static charts](./static-charts)
* [Filesystem downloads](../filesystem/downloads)
