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

Binding shift zoom does not work on second layered chart #3767

Open
mrkbutty opened this issue Jan 10, 2025 · 0 comments
Open

Binding shift zoom does not work on second layered chart #3767

mrkbutty opened this issue Jan 10, 2025 · 0 comments
Labels
bug needs-triage Bug report needs maintainer response

Comments

@mrkbutty
Copy link

mrkbutty commented Jan 10, 2025

What happened?

I am attempting to bind the shift wheel zoom so that Y axis only zooms when shift is held.
The code below mostly works... zooming without shift only zooms the x axis.
Zooming with shift held will zoom the y axis only on the left, but the right side y2 remains static.

If I remove the "bind_y=False" and the zoom params from the following code then all three x, y, y2 zoom together.

Grateful for any help?

import altair as alt
import pandas as pd

df1=pd.DataFrame({'x':[1,2,3,4,5], 'y':[1,2,3,4,5]})
df2=pd.DataFrame({'x':[1,2,3,4,5], 'y2':[500,400,300,200,100]})

left = alt.Chart(df1).mark_line(point={'size':50}).encode(
    x = 'x',
    y = 'y',
).interactive(bind_y=False)

right = alt.Chart(df2).mark_line(point={'size':50, 'color':'red'}, color='red').encode(
    x = 'x',
    y = 'y2',
).interactive(bind_y=False)

chart = alt.layer(left, right).resolve_scale(y='independent')
xzoom = alt.selection_interval(encodings=['x'], bind="scales", zoom="wheel![!event.shiftKey]")
yzoom = alt.selection_interval(encodings=['y'], bind="scales", zoom="wheel![event.shiftKey]")
chart = chart.add_params(xzoom, yzoom)
chart

What would you like to happen instead?

I would like the y2 to zoom at the same rate as y, similar to normal zoom operation of x+y when not using the selection_interval params.

Which version of Altair are you using?

5.0.1

@mrkbutty mrkbutty added the bug label Jan 10, 2025
@dangotbanned dangotbanned added the needs-triage Bug report needs maintainer response label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Bug report needs maintainer response
Projects
None yet
Development

No branches or pull requests

2 participants