-
Notifications
You must be signed in to change notification settings - Fork 586
Open
Description
I'm trying to render an Altair chart in an ipywidget.Output widget. Altair charts properly render with Voila, but not nbconvert.
Here is a test notebook I created to replicate the issue.
# test.ipynb
import ipywidgets as widgets
import pandas as pd
import altair as alt
source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]})
output_donut = widgets.Output()
with output_donut:
donut = alt.Chart(source).mark_arc(innerRadius=50).encode(
theta=alt.Theta(field="value", type="quantitative"),
color=alt.Color(field="category", type="nominal"),
)
donut.display()
output_donut
If I run the cell, the Altair chart displays properly.
Rendering with voila renders the chart:
voila test.ipynb
When I run nbconvert
, it looks like the <div>
along with the <script>
gets rendered as text. I ran the following to try and somewhat replicate what Voila does.
jupyter nbconvert --to HTML --no-input --execute test.ipynb
I have read through a few related issues, including some weird display ordering. I haven't found anything that works properly. It looks like the other solutions might have worked in older versions of nbconvert
. Here are the versions I'm using for this example.
altair==4.2.2
nbconvert==7.2.9
pandas==1.5.3
Metadata
Metadata
Assignees
Labels
No labels