# test interactive chart in github blog
import polars as pl
import altair as alt
# make DatraFrame
df = pl.DataFrame( {
'a' : [ 1, 3 ,4 ],
'b' : [ 1, 3, 4 ],
'c' : [ 3, 8, 4 ]
} )
# Visualiztion with altair
sel = alt.selection_point( fields = [ 'key' ] )
base = alt.Chart( df ).transform_fold(
df.columns
).encode(
alt.X( 'key:N' )
)
bar = base.mark_bar().encode(
alt.Y( 'sum(value):Q' )
)
circle = base.mark_circle().encode(
alt.Size( 'sum(value):Q' ).legend( None )
)
alt.vconcat(
circle.add_params( sel ), bar.transform_filter( sel )
).configure_axis(
title = None, labelAngle = 0, grid = False
).configure_view( stroke = None )