Altair: Blank tooltips for datetime64[ns]

Created on 14 Dec 2018  路  4Comments  路  Source: altair-viz/altair

This basic chart renders as expected, except that the "date" value in the tooltip is blank:

import altair as alt
from vega_datasets import data

alt.Chart(data.stocks()).mark_point().encode(
    x='date',
    y='price',
    tooltip=['date', 'price', 'symbol']
)

chart

This can be fixed by specifying an explicit format with e.g. alt.Tooltip('date', format='%d/%m/%Y'), but it might make sense to have a default format?

bug vega-lite-related

Most helpful comment

A more concise way to do the same thing is

tooltip=['yearmonthdate(date)', 'price', 'symbol']

All 4 comments

It looks like a Vega-Lite issue; it seems to have been fixed in Vega-Lite 3: vega editor link.

I've noticed that passing timeUnit when using a long-form ToolTip is a good workaround, albeit slightly more verbose.

alt.Chart(data.stocks()).mark_point().encode(
    x='date',
    y='price',
    tooltip=[
        alt.Tooltip('date', timeUnit='yearmonthdate'),
        alt.Tooltip('price'),
        alt.Tooltip('symbol'),
    ],
)

A more concise way to do the same thing is

tooltip=['yearmonthdate(date)', 'price', 'symbol']

Confirmed that this is fixed in Altair 3.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakevdp picture jakevdp  路  23Comments

Hisham-Hussein picture Hisham-Hussein  路  29Comments

noklam picture noklam  路  20Comments

jakevdp picture jakevdp  路  48Comments

jakevdp picture jakevdp  路  17Comments