question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format multi tooltip

See original GitHub issue

Hello, I cannot find a way to provide a format for each field of a multi tooltip. Here is a reproducible example :

import pandas as pd
import numpy as np
import altair as alt

np.random.seed(14)
data = pd.DataFrame({"date": pd.date_range("2018-01-01", periods=100),
                     "values": np.random.normal(size=100)})

alt.Chart(data).mark_point().encode(
    x="date:T",
    y="values:Q",
    tooltip=alt.Tooltip(['date:T', 'values:Q'], format='.2f')
)

Which formats also the date field: screenshot from 2018-06-12 18-06-09 If I try something like

alt.Tooltip(['date:T', 'values:Q'], format=['%d/%m/%Y', '.2f'])

I have an error saying that format is not a string.

So, how can I specify the format of each field in this multi tooltip ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
jakevdpcommented, Jun 12, 2018

You can set the encoding to a list of alt.Tooltip objects, each with their own format string:

import pandas as pd
import numpy as np
import altair as alt

np.random.seed(14)
data = pd.DataFrame({"date": pd.date_range("2018-01-01", periods=100),
                     "values": np.random.normal(size=100)})

alt.Chart(data).mark_point().encode(
    x="date:T",
    y="values:Q",
    tooltip=[alt.Tooltip('values:Q', format='.2f'),
             alt.Tooltip('date:T', format='%A, %B %e')]
)
screen shot 2018-06-12 at 9 16 48 am
2reactions
tonylee3399commented, Apr 20, 2020

Just for additional information, if you need to show DateTime format in your tooltip, you could refer to this d3-time-format

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple Series - Tooltip format - Highcharts official support forum
I'm using high stock to represent multi series zoomable chart. In this case, I want to group the tooltip into a single tooltip...
Read more >
how to add formatter tooltip in echart for multiple values for pie ...
I am using echart pie diagram but I want to show multiple records in tooltip. option = { tooltip ...
Read more >
Multiple y-axis - different tooltip formats - CodePen
CSS ; 1. #chart { ; 2. max-width: 650px; ; 3. margin: 35px auto; ; 4. } ; 5. ​.
Read more >
PDF form fields | Add tooltips, data and time, reqired/optional ...
Learn how to use form fields properties to add tooltip, date & time, required or not required, multi-line text, and calculated values in...
Read more >
How to customize tooltips - Datawrapper Academy
Emphasize text with HTML · Create a mini-table · Add extra information about certain regions · Add two numbers together · Change the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found