Announcing VegaFusion 1.3
Transformed data for compound charts, Java library
By: Jon Mease
The VegaFusion team is happy to announce the release of version 1.3. Along with usual bug fixes and updates to the core Arrow and DataFusion dependencies, this release includes an enhancement to the transformed_data
function to make it compatible with compound charts, adds DuckDB 0.8 support, and adds a new Java API.
Extract transformed data from compound Altair charts
The VegaFusion transformed_data
function can be used to extract the transformed data from an Altair chart object as a pandas DataFrame. Prior to 1.3.0, transformed_data
was only supported on simple charts that involve only a single mark. Now, compound layered and concatenated charts are supported as well. In the case of a compound chart, transformed_data
will return a list of pandas DataFrame’s rather than single DataFrame.
Example: Histogram with a Global Mean Overlay
Here is an example based on the Histogram with a Global Mean Overlay example from the Altair gallery.
import altair as alt
import vegafusion as vf
from vega_datasets import data
vf.enable()
source = data.movies.url
base = alt.Chart(source)
bar = base.mark_bar().encode(
alt.X('IMDB_Rating:Q').bin().axis(None),
y='count()'
)
rule = base.mark_rule(color='red').encode(
x='mean(IMDB_Rating):Q',
size=alt.value(5)
)
chart = bar + rule
chart
Because chart
is composed of two subcharts, the result of vf.transformed_data
will be a list of two DataFrames.
[hist_df, rule_df] = vf.transformed_data(chart)
hist_df
| | bin_maxbins_10_IMDB_Rating | bin_maxbins_10_IMDB_Rating_end | __count |
|---:|-----------------------------:|---------------------------------:|----------:|
| 0 | 6 | 7 | 985 |
| 1 | 3 | 4 | 100 |
| 2 | 7 | 8 | 741 |
| 3 | 5 | 6 | 633 |
| 4 | 8 | 9 | 204 |
| 5 | 2 | 3 | 43 |
| 6 | 4 | 5 | 273 |
| 7 | 9 | 10 | 4 |
| 8 | 1 | 2 | 5 |
rule_df
| | mean_IMDB_Rating |
|---:|-------------------:|
| 0 | 6.28347 |
DuckDB 0.8 Support
VegaFusion’s DuckDB integration has been updated to support DuckDB 0.8.0
Java API
VegaFusion 1.3 may now be embedded in Java applications using the new io.vegafusion.vegafusion
jar, which is published to Maven Central.
This was accomplished by wrapping the VegaFusion Rust API with a JNI interface using the jni-rs
crate.
Updates to Arrow and DataFusion dependencies
VegaFusion 1.3 updates the dependency on arrow-rs to version 39.0 and DataFusion to version 25.0.
Learn more
Check out these resources to learn more: