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

maxgerma picture maxgerma  路  3Comments

morberg picture morberg  路  3Comments

pabloinsente picture pabloinsente  路  3Comments

Juan-132 picture Juan-132  路  3Comments

tonylee3399 picture tonylee3399  路  3Comments