[英]Altair scrollable chart
I am trying to plot data for each day.我正在尝试绘制每天的数据。 Depending on the selection of the data it can be a few days, or multiple months.
根据数据的选择,它可以是几天,也可以是几个月。 In both cases i want the same scale (1 bar per day)
在这两种情况下,我都想要相同的比例(每天 1 bar)
I can plot the data per day with no problem.我可以毫无问题地每天绘制数据。 The chart is also scrollable, but if i have selected multiple month, it still only shows 30 days.
图表也是可滚动的,但如果我选择了多个月份,它仍然只显示 30 天。 If i scroll left/right, there is no data.
如果我向左/向右滚动,则没有数据。 What am i missing?
我错过了什么?
timeunit='date'
a = alt.Chart(data).mark_bar(opacity=0.6).encode(
x=alt.X('date(Gemeldet_Am):T',
timeUnit=timeunit,
axis=alt.Axis(title='Zeitfenster', grid=False)),
y=alt.Y('count(ABC):Q',
axis=alt.Axis(title='Number of calls',grid=True)),color='mean(Sentiment):Q',
tooltip=[alt.Tooltip('count(ABC):Q'),
alt.Tooltip('mean(Sentiment):Q',title='Sentiment')]).interactive()
b = alt.Chart(data).mark_line(color='orange', interpolate='monotone').encode(
x=alt.X('date(Gemeldet_Am):T',
timeUnit=timeunit),
y='mean(Sentiment):Q').interactive()
It works for me if I define the bar size and the step size:如果我定义条形大小和步长,它对我有用:
alt.Chart(df).mark_bar(width=20)\
.encode(...)
.properties(with=alt.Step(30))
now each bar will have a width of 20 pixels and will take 30 pixels width.现在每个条的宽度为 20 像素,宽度为 30 像素。 The total width of your chart will have 30 * number of columns.
图表的总宽度将有 30 * 列数。 You will get a horizontal scroll bar if it does not fit your browser window.
如果它不适合您的浏览器窗口,您将看到一个水平滚动条。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.