-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Vertical or/and horizontal line that is always shown in any hovermode #2155
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
Comments
This looks very useful @apalchys ! To make sure I'm understanding the PR correctly, this new hover mode would be enabled by setting:
The @chriddyp and @cpsievert - Any opinions on this feature from a Dash and Shiny perspective? In particular, from the PR description #2150
Thoughts @alexcjohnson ? Seems like a reasonable addition to me. Just curious @apalchys - in which financial software have you seen this feature? Looks like Highcharts has a similar hover line on the x-axis for example: https://www.highcharts.com/stock/demo/lazy-loading |
This feature has already been requested a couple times by the dash community:
For the api, does it make sense to match the existing
Note that this is pretty similar to |
It's similar enough that we should really try to extend the spikes feature rather than add a new competing one.
TBH I'm not sure it's desirable for spikes to depend on
Do you mean this to be linked to hover behavior (ie there's no limit to max hover distance as far as hover data AND spikes) or do you mean spikes should show up all the time (based on the nearest point) but hover data should only show up when you're within our predefined max distance? The former seems clearer to me (and notice that it would encompass spikes-only mode, if used with
In retrospect we probably should have put spike styling into a sub-container, but at this point I don't think we want to change the existing spike styling API until v2.0 |
If interested in another comparison it looks amcharts has a version of this feature: |
Interesting... per one of the pieces of #2026:
In the amcharts version, the vertical spike is pinned to the data point while the horizontal is pinned to the cursor, even though the hover label is pinned to the data - to support that, we'd need spike positioning to be a per-axis configuration independent of hover label positioning. |
I personally would love to have a feature like this implemented. @chriddyp already explained in #1847 the question I raised in the dash forum. Since it seems to be a general brainstorming here again, I would like to throw in another extension of this feature that I really would appreciate: It would be wonderful if this hovering line could be extended to reach over multiple stacked subplots. Here you can see an example. I didn't take a into-depth look to this PR but I guess it's limited to one plot? Since this seems to be a more general discussion of where to go with this feature, I would really like to see this possibility supported as well. |
@kratzert |
It sounds reasonable, I think that we can do it this way and extend the existing spikes functionality by making it work in any
At the moment, the second one is implemented. Crosslines are displayed all the time (based on the nearest point), but the hover data is displayed only when you're within predefined max distance (this is certainly discussable)
The idea of |
Yes, you understood this correctly, in the current implementation this feature can be switched on by setting the corresponding axis |
We can use one more parameter, for example |
Yes, highcharts/amcharts has this feature. Also many other less popular libraries provides this feature: e.g. http://techanjs.org or https://api.taucharts.com/basic/line.html From my experience, users from financial area likes to have a vertical line for analyzing line/stock charts. |
I second @alexcjohnson 's remark that we should try as much as possible to extend the existing To enable the proposed behavior, we could add addition
For backward-compatibility, we could add |
I added support for Could someone please review it before I open PR? |
Hmm. Before I dig deeper into your patch. Looks like the default Master: http://rickyreusser.com/plotly-mock-viewer/#stacked_coupled_subplots your branch master...apalchys:crossline we can't allow that to happen. |
Oh wait, I see why this is happening. You remove the fancy modebar logic that pinned hovermode to Off your branch with This functionality should be covered already by |
New functionality allows to work with spikes in the "compare" mode when there are several traces on the same plot and it does not depend on Just to summarize: Also now we have the ability to stick the spikeline to the cursor, not to the data points, and to set the searching distance for points for drawing the hoverlabels and spikelines. Here are some examples of new functionality: |
Ok. Then why does this new functionality depend on |
@etpinard are you asking why the feature depends on |
Found another decent example of this feature in ChartIQ: |
I like the vertical line aspect, but then cant we turn the horizontal line off. As the cursor moves horizontally the yvalues are reflected on the plots. The horizontal line to a certain extent is not giving out any information. My other question is can this be extended to subplots as mentioned in Hover labels across shared axes. |
@deechiw
By doing this, you turn on the vertical spikeline (spikeline to the shared xaxis) and set the range for drawing it to Infinity. And in the compare mode, it will be drawn by default across all subplots. You can also set the
Below are examples of this spikelines behavior for such settings. (here is the demo: https://codepen.io/plotly-demo/pen/BmgGMq) As for the hover labels for other subplots, I agree with @alexcjohnson on his comment #2155 (comment):
|
That's great. That's for fixing that.
I'm confused here. Now that hover and spike data are independent, why would the behavior depend on
That's very nice. Thanks for adding this 👌 |
TL;DR
Long explanation At the moment, spikelines are used in the In Therefore, we simply cannot use the
The answer to this question is closely related to the previous one. But, as I already mentioned, in |
@apalchys I think this is making it too complicated, and somewhere in there it will lead to undesirable behavior. I haven't looked at it in enough detail to know where, though it seems like a) you've brought a bunch of I think as far as spikelines are concerned, we SHOULD just select one point for drawing both spikelines, and do this process completely independently from selecting hover data. Hover data makes one loop through the data, using I suppose when |
@apalchys neat effect with the grey and red/green lines, really makes it easy to see what's going on! I think spikelines should always behave like what you have for This will mean sometimes spikelines will appear or disappear independently of the hover labels - sometimes we'll have only hover labels, sometimes only spike lines - but especially with the distinction between |
Not at all! It's really important that we get the goals right before going any further.
Yes, that's certainly desirable! I think we're pretty close though in your first gif above (with the green circle and grey rectangle). You really have to go looking for situations where the spikes and hover labels disagree. What about a small tweak to the behavior to cover that case:
Note that this way there is still no explicit coupling between hovermode and spike mode, just a coupling between the points chosen by each feature. |
@alexcjohnson Thank you for your ideas, I've reworked my code a bit according to them. Now it works like this:
What do you think about this behavior? Did I understand you correctly? |
I am going to create a PR with my latest changes mentioned in #2155 (comment). Does it make sense? |
I'd say: go for it! |
PR has been merged. Closing the issue. |
Thanks for getting in this PR it has been super helpful. For anyone looking to achieve this functionality here is the layout that I used. I overlooked @apalchys comment a few times before I realized his codepen link. Hope this helps someone in the future :).
|
@apalchys How did you achieve this? What settings are required for it? |
Wondering the same :) I'm also trying to find out how to add highlighted zones in the background (as of now I only found shapes which I could use to do it... but I'm not sure it is the intended use of shapes...) |
@sleighsoft try this:
what bugs me is: how to disable the hover box on the chart; and always show the outer axis box with the coordinate of the cursor (not data point)? |
How to easy use crossline in python? |
It would be nice to have an option in plotly.js to toggle on a vertical or/and horizontal line across the entire plot area on hover.
The behavior of the line should be similar to the behavior of the spikes feature, but there are several differences:
This feature could be very useful for financial and stock charts
Related to #2026, #1959
PR #2150
The text was updated successfully, but these errors were encountered: