Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: encodings with multiple fields (e.g. tooltip) #825

Closed
jakevdp opened this issue May 8, 2018 · 1 comment
Closed

ENH: encodings with multiple fields (e.g. tooltip) #825

jakevdp opened this issue May 8, 2018 · 1 comment

Comments

@jakevdp
Copy link
Collaborator

jakevdp commented May 8, 2018

We need to update the encode() method so that it will handle multiple encoding fields in cases where it is supported.

For example, in the most recent vega-lite release, it is possible to pass multiple fields to the tooltip encoding:

from vega_datasets import data
cars = data.cars()

chart = alt.Chart(cars).mark_point().encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin'
)

chart.encoding.tooltip = [{'field': 'Name', 'type': 'nominal'},
                          {'field': 'Origin', 'type': 'nominal'}]

chart

screen shot 2018-05-08 at 10 37 35 am

Altair should make this available via a more simplified API, such as

from vega_datasets import data
cars = data.cars()

chart = alt.Chart(cars).mark_point().encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin',
    tooltip=['Name', 'Origin']
)
@kanitw
Copy link
Member

kanitw commented May 8, 2018

detail also support multiple fields (since v1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants