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

[plotly] jump to custom data index if available #607

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

PythonFZ
Copy link
Member

@PythonFZ PythonFZ commented Aug 9, 2024

If you provide customdata, e.g. via

l1 = pd.DataFrame({"x": [1, 2, 3], "y": [0, 1, 2], "idx": [0, 1, 2], "line_id": "line_1"})
l2 = pd.DataFrame({"x": [1, 2, 3], "y": [0.5, 1.5, 2.5], "idx": [3, 4, 5], "line_id": "line_2"})

# Combine the DataFrames
df = pd.concat([l1, l2])

# Plotting the lines
fig = px.line(df, x="x", y="y", color="line_id", hover_data=["idx"])
vis.figure = fig.to_json()

plotly will jump to the first item in customdata instead of the pointIndex.

@PythonFZ PythonFZ merged commit 0ecde2b into main Aug 9, 2024
4 checks passed
@PythonFZ PythonFZ deleted the plotly-customdata-jump branch August 9, 2024 08:33
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

Successfully merging this pull request may close these issues.

1 participant