【发布时间】:2021-01-07 17:31:53
【问题描述】:
我想结合 Altair 文档中的两个示例来获得垂直滚动条形图的能力。一个用例是甘特图。
目前我只能水平滚动,图表内容被压缩到我定义的高度属性:
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
)
如何配置图表以保留原始比例并允许在定义的高度内滚动?
谢谢!
【问题讨论】:
标签: python charts scroll scaling altair