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

Clicks are sometimes missed with clickmode layout key #6898

Open
willhuang1997 opened this issue Feb 14, 2024 · 4 comments
Open

Clicks are sometimes missed with clickmode layout key #6898

willhuang1997 opened this issue Feb 14, 2024 · 4 comments

Comments

@willhuang1997
Copy link

Hi,

This is William Huang from the Streamlit Open Source team!
I am currently attempting to provide selection on charts for the Streamlit st.plotly_chart api. I noticed there are on_select and on_click callbacks that we can register to. The on_click callbacks always register and that seems fine.

However, when I try to use the clickmode: “event+select” in the layout of the graph, clicks are sometimes missed. This can be replicated here:
Plotly.js - JSFiddle - Code Playground
or here:
Plotly Playground - JSFiddle - Code Playground 1

Is there someone that can help me to understand why clicks are being missed? We are trying to release this feature within streamlit so any help would be appreciated!

I created a demo app here: https://chart-selections-demo.streamlit.app/ that uses this clickmode layout property. (FEEL FREE TO CHECK OUT 😉 )

@alexcjohnson
Copy link
Collaborator

Thanks @willhuang1997 - please note, plotly-latest is stuck on v1.x; to use v2.x you need to use an explicit version number. Can you update the fiddles to use v2.29.1? Is the behavior still buggy? If so, say more about exactly what you've observed - is there a specific sequence of clicks that consistently causes problems?

@willhuang1997
Copy link
Author

Hi @alexcjohnson , thanks for getting back to me!

I updated this fiddle to 2.29.1. The behavior is still buggy from my perspective.

What I expect: I click once I see the hover label and the bar should highlight.
What I observe: I click once I see the hover label appear on the screen. The clicks inconsistently highlight the bar that is currently showing the hoverlabel.

When you see the label disappear, it means that I am clicking in this gif.
Here is a gif to demonstrate such:
Screen_Recording_2024-02-14_at_7 14 15 PM_V1

I have tried registering the onClick behavior with saving state within some react component as to what point as been clicked and that consistently works. However, I didn't understand how to change the color of the marker that is clicked with a developer that is using plotly.express while making everything else opaque. It's important from product perspective for the users to understand what has been selected through the graph so we started using the clickmode: "event+select" in order to get that highlighting through the plotly library. However, we noticed that clicks are inconsistent as can be seen in the gif above.

@Lexachoc
Copy link

Lexachoc commented Feb 22, 2024

@willhuang1997 Hi there, good demo app!
I wonder if the full screen button in the upper right corner is the Streamlit feature or your customization for Plotly?
image

BTW, I also noticed that a rangeslider bug in https://chart-selections-demo.streamlit.app/#selections-for-a-candlestick-chart and in your JSFiddle examples, that you might want to follow if you think it's relevant, see the issue I asked recently.

@willhuang1997
Copy link
Author

Hi @Lexachoc , the fullscreen button is a streamlit full screen button.

Also, thanks for letting me know the bug is there for candlestick charts!

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

No branches or pull requests

4 participants