v0.11.0-rc11 #204
Replies: 7 comments 9 replies
-
Here is some of the draft documentation for the website that will be updated along with the release of 0.11.0. VegaFusionVegaFusion provides serverside scaling for the Vega visualization library. While not limited to Python, an initial application of VegaFusion is the scaling of the Altair Python interface to Vega-Lite. The core VegaFusion algorithms are implemented in Rust. Python integration is provided using PyO3 and JavaScript integration is provided using wasm-bindgen. Quickstart 1: Overcome
|
bin_maxbins_30_delay | bin_maxbins_30_delay_end | __count | |
---|---|---|---|
0 | -20 | 0 | 419400 |
1 | 80 | 100 | 11000 |
2 | 0 | 20 | 392700 |
3 | 40 | 60 | 38400 |
4 | 60 | 80 | 21800 |
5 | 20 | 40 | 92700 |
6 | 100 | 120 | 5300 |
7 | -40 | -20 | 9900 |
8 | 120 | 140 | 3300 |
9 | 140 | 160 | 2000 |
10 | 160 | 180 | 1800 |
11 | 320 | 340 | 100 |
12 | 180 | 200 | 900 |
13 | 240 | 260 | 100 |
14 | -60 | -40 | 100 |
15 | 260 | 280 | 100 |
16 | 200 | 220 | 300 |
17 | 360 | 380 | 100 |
Quickstart 3: Accelerate interactive charts
While the VegaFusion mime renderer works great for static Altair charts, it's not as well suited for interactive charts visualizing large datasets. This is because the mime renderer does not maintain a live connection between the browser and the python kernel, so all the data that participates in an interaction must be sent to the browser.
To address this situation, VegaFusion provides a Jupyter Widget based renderer that does maintain a live connection between the chart in the browser and the Python kernel. In this configuration, selection operations (e.g. filtering to the extents of a brush selection) can be evaluated interactively in the Python kernel, which eliminates the need to transfer the full dataset to the client in order to maintain interactivity.
The VegaFusion widget renderer is provided by the vegafusion-jupyter
package.
Instead of enabling the mime render with vf.enable_mime()
, the widget renderer is enabled with vf.enable_widget()
. Here is a full example that uses the widget renderer to display an interactive Altair chart that implements linked histogram brushing for a 1 million row flights dataset.
import pandas as pd
import altair as alt
import vegafusion as vf
vf.enable_widget()
flights = pd.read_parquet(
"https://vegafusion-datasets.s3.amazonaws.com/vega/flights_1m.parquet"
)
brush = alt.selection(type='interval', encodings=['x'])
# Define the base chart, with the common parts of the
# background and highlights
base = alt.Chart().mark_bar().encode(
x=alt.X(alt.repeat('column'), type='quantitative', bin=alt.Bin(maxbins=20)),
y='count()'
).properties(
width=160,
height=130
)
# gray background with selection
background = base.encode(
color=alt.value('#ddd')
).add_selection(brush)
# blue highlights on the selected data
highlight = base.transform_filter(brush)
# layer the two charts & repeat
chart = alt.layer(
background,
highlight,
data=flights
).transform_calculate(
"time",
"hours(datum.date)"
).repeat(column=["distance", "delay", "time"])
chart
flights_brush_histogram.mov
Histogram binning, aggregation, and selection filtering are now evaluated in the Python kernel process with efficient parallelization, and only the aggregated data (one row per histogram bar) is sent to the browser.
You can see that the VegaFusion widget renderer maintains a live connection to the Python kernel by noticing that the Python kernel is running as the selection region is created or moved. You can also notice the VegaFusion logo in the dropdown menu button.
Supported Environments
VegaFusion can display Altair visualizations is the following contexts
Classic Notebook
Both the VegaFusion mime and widget renderers are compatible with version 6 of the Jupyter Notebook (Sometimes referred to as the Classic Notebook since it predates JupyterLab). The Classic Notebook extension containing the VegaFusion widget is included in the vegafusion-jupyter
Python package, and it is enabled automatically when the package is installed. The mime renderer should be enabled with the "html"
mimetype:
import vegafusion as vf
vf.enable_mime(mimetype="html")
...
JupyterLab
Both the VegaFusion mime and widget renderers are compatible with version 3+ of JupyterLab. The JupyterLab extension containing the VegaFusion widget is included in the vegafusion-jupyter
Python package, and it is enabled automatically when the package is installed.
Voila
Both the VegaFusion mime and widget renderers are compatible with the Voila dashboard toolkit. This works with or without the enable_nbextensions
flag.
Visual Studio Code
Both the VegaFusion mime and widget renderers are compatible with Visual Studio Code Python notebooks. The widget extension will be downloaded automatically from a CDN location, so an active internet connection is required to use the widget renderer.
Hex
The VegaFusion mime renderer is compatible with the Hex notebook. VegaFusion comes pre-installed and the mime renderer can be enabled as usual.
import vegafusion as vf
vf.enable_mime()
...
The widget renderer is not compatible with Hex.
Colab
The VegaFusion mime renderer is compatible with Google Colab when the "html-colab"
mimetype is enabled:
%pip install vegafusion[embed]
import vegafusion as vf
vf.enable_mime(mimetype="html-colab")
...
The VegaFusion widget renderer is also compatible with Google Colab when the custom widget manager is enabled:
%pip install vegafusion-jupyter[embed]
from google.colab import output
output.enable_custom_widget_manager()
import vegafusion as vf
vf.enable_widget()
...
Kaggle
The VegaFusion mime renderer is compatible with Kaggle Notebooks when the "html-kaggle"
mimetype is enabled:
%pip install vegafusion[embed]
import vegafusion as vf
vf.enable_mime(mimetype="html-kaggle")
...
The widget renderer is not currently compatible with Kaggle.
Beta Was this translation helpful? Give feedback.
-
cc @binste @joelostblom @mattijn @nicolaskruchten @domoritz @dhirschfeld as this release candidate includes some features I've mentioned to you all over the past 4 months 😄 If anyone has a chance to give the release candidate a try, feel free to drop feedback in this thread. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Let me know if anyone has opinions on which mime bundle type should be the default. I'm waffling between the
|
Beta Was this translation helpful? Give feedback.
-
Maybe it's more intuitive for users if it's the same as in Altair, i.e. If I find some time this week to try out the release candidate, I'll make sure to let you know in case I'd find something. Thank you in any case, really looking forward to the release! |
Beta Was this translation helpful? Give feedback.
-
New release candidate over in #213 |
Beta Was this translation helpful? Give feedback.
-
Latest RC in #225. Note that I decided to skip 0.11.0 and go right to 1.0.0 since this release is the most significant one since VegaFusion was first announced (in particular, the mime renderer, transformed_data function). In terms of timeline, I'm aiming to release 1.0.0 final with docs and announcement material before the end of the month (hopefully sooner!). |
Beta Was this translation helpful? Give feedback.
-
I finally had some time to play with vegafusion in the last two weeks and I've to say its really neat. Before we wrote custom aggregation query using duckdb-sql syntax and pipe it into the chart for really large tables, but now one can stick to the vega-altair/lite syntax without writing additional queries and still handle large tables. |
Beta Was this translation helpful? Give feedback.
-
Release candidate for 0.11.0-rc11
This version introduces a brand new mime-type based renderer that is compatible with many notebook and compute environments without requiring custom extensions. It also includes a new
transformed_data()
function that makes it possible to evaluate the data transforms associated with an AltairChart
and return the result as a pandas DataFrame. Finally, support was added for several additional Vega transforms includingpivot
andimpute
.Installation
To try out the release candidate:
This discussion was created from the release v0.11.0-rc11.
Beta Was this translation helpful? Give feedback.
All reactions