I would like to combine two examples from Altair documentation to gain the ability to scroll through a bar-chart vertically. One use case of this would be a Gantt chart.
Presently I only gain the ability to scroll horizontally, with the chart content being squashed to the height property that I define:
import altair as alt
from vega_datasets import data
source = data.wheat()
bars = alt.Chart(source).mark_bar().encode(
x='wheat:Q',
y="year:O"
)
text = bars.mark_text(
align='left',
baseline='middle',
dx=3 # Nudges text to right so it doesn't appear on top of the bar
).encode(
text='wheat:Q'
)
selection = alt.selection_interval(bind='scales')
(bars + text).properties(height=300).add_selection(
selection
)
How can I configure the chart to retain the original proportions and allow scrolling within the defined height?
Thank you!
question from:
https://stackoverflow.com/questions/65617233/python-altair-bar-chart-scale-binding 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…