简体   繁体   中英

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)

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. 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. The total width of your chart will have 30 * number of columns. You will get a horizontal scroll bar if it does not fit your browser window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM