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

Flicker-free interaction with ipywidgets? #333

Closed
afonit opened this issue May 23, 2017 · 2 comments
Closed

Flicker-free interaction with ipywidgets? #333

afonit opened this issue May 23, 2017 · 2 comments
Milestone

Comments

@afonit
Copy link
Contributor

afonit commented May 23, 2017

I have seen some demos of plots with ipywidgets that are really smooth and flicker-free. Is that possible with altair 1.0? or is that more of 2.0 and the jupyter lab integration?

Here is my current simple example that flickers in jupyter notebook:

import pandas as pd
import altair as alt
from ipywidgets import interact
from ipywidgets import IntSlider

data = {'a': ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],
       'b':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}

df = pd.DataFrame(data)

def some_plot(value):
    chart = alt.Chart(df).mark_line().encode(
    x='a',
    y='b').transform_data(filter='datum.b < %s' % value)
    return chart

interact(some_plot, value=IntSlider(min=1, max=10, step=1))
@ellisonbg
Copy link
Collaborator

A couple of things you are running into:

  • The data transfer and rendering time of Vega-Lite is probably not fast enough to have a nice interactive experience.
  • We would need to build a full ipywidget version of a Vega-Lite rendering to create nice experience for this.

Building a ipywidget version of a Vega-Lite renderer wouldn't be too difficult, however, Vega-Lite doesn't have many APIs for updating a visualization. Thus, all we could really do is re-render from scratch, which still might be an issue. Something to think about in the long term though.

@ellisonbg ellisonbg added this to the Future milestone Sep 27, 2017
@ellisonbg ellisonbg changed the title flicker-free interaction with ipywidgets? Flicker-free interaction with ipywidgets? Sep 27, 2017
@joelostblom
Copy link
Contributor

It is now possible to use the JupyterChart class to create Altair charts that can interact with jupyter/ipywidgets directly and without any flicker. See this section in the docs for details https://altair-viz.github.io/user_guide/jupyter_chart.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants