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

Altair demo from medium article broken #381

Closed
penningavery opened this issue Nov 17, 2023 · 2 comments
Closed

Altair demo from medium article broken #381

penningavery opened this issue Nov 17, 2023 · 2 comments

Comments

@penningavery
Copy link

penningavery commented Nov 17, 2023

Hi,

I tried the altair demo: https://blog.jupyter.org/anywidget-jupyter-widgets-made-easy-164eb2eae102
Including the colab demo: https://colab.research.google.com/gist/manzt/2b83d3461c40ac7b43fde29515cb8077/extending_altair_with_anywidget.ipynb#scrollTo=73484882-7670-4711-91ef-3a4c09945ae6

But the cell here fails/the control is not interactive:
Screenshot (341)

The altair widget in the first interactive cell seems to work, so I'm not sure what's happening with the anywidget version.

I tried it on a local install and it failed there too. Note in both colab and my local install the counter demo works fine.

Looks like a very useful library, thanks!

@manzt
Copy link
Owner

manzt commented Nov 17, 2023

Hi there, it seems there is a bug in the latest release of Vega. Until that is resolved, you'll need to update this cell:

import anywidget
import traitlets


class ChartWidget(anywidget.AnyWidget):
    _esm = """
--  import embed from "https://cdn.jsdelivr.net/npm/vega-embed@6/+esm";
++  import embed from "https://esm.sh/vega-embed@[email protected]";

    export async function render({ model, el }) {
        let spec = JSON.parse(model.get("spec"));
        let api = await embed(el, spec);
        api.view.addSignalListener(spec.params[0].name, (_, update) => {
            console.log(update);
            model.set("selection", update);
            model.save_changes();
        });
    }
    """
    spec = traitlets.Unicode().tag(sync=True)
    selection = traitlets.Dict().tag(sync=True)

To be clear, this is a bug in one of the JavaScript dependencies in the blog post (Vega) not anywidget. The other examples in our documentation should still work! Thanks for reporting, and hopefully it gets resolved soon.

@penningavery
Copy link
Author

Hi,

Thanks very much for the quick response, the example is working for me now!

Cheers,

Avery

@manzt manzt closed this as completed Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants