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

Bar chart: draw the outline, even if the height is zero. #3797

Closed
RichardNeill opened this issue Apr 22, 2019 · 5 comments · Fixed by #3848
Closed

Bar chart: draw the outline, even if the height is zero. #3797

RichardNeill opened this issue Apr 22, 2019 · 5 comments · Fixed by #3848
Assignees
Milestone

Comments

@RichardNeill
Copy link

For a bar of zero height, if the line width is specified, we should be able to see the bar border, even though we don't see the bar.

In this example:
https://codepen.io/RichardNeill/pen/EJRqmN

B is a normal bar, with 10px border, as it should be.
C is a bar with height = null. It is, correctly, completely invisible.

But A is a bar with height = 0. It should actually appear as a 20px high rectangle (the border should still be displayed), even though the bar area itself isn't. Try setting the value to 0.0001
and you'll see what I expect. In addition, the hover tooltip is (wrongly) suppressed - it doesn't appear in "show closest data on hover" mode.

@etpinard
Copy link
Contributor

Thanks for writing in.

we should be able to see the bar border, even though we don't see the bar.

Can I ask why that's the desired behavior in your use case?

@alexcjohnson
Copy link
Collaborator

This makes sense to me from a continuity standpoint - tiny positive and tiny negative look identical, but in between at exactly zero there’s a gap? If you’ve added a border to your bars you’re asking users to implicitly remove the border in evaluating bar size, so why should zero be an exception?

Also re: hover - makes sense to include the lines, though this gets tricky if there’s overlap like stacking.

@RichardNeill
Copy link
Author

Thanks. Consider, for example, a bar chart showing temperature vs date. I need a way to distinguish 0 ("today, the temperature was 0 degrees") from null (today was a weekend and I didn't record the temperature).

I think that Plotly correctly handles nulls by not plotting the point at all, nor does it give a hover.

But it's imperfect for zeros: a zero-height bar is treated more like a null-bar than a zero-valued bubble.
I think Ploty should:

  • include the bar borders, or show a really thin bar
  • show the hover tooltip (as it would for a 0.00001 bar)

(I also show the word "zero" as text, with textposition=outside; this is an option which is already available).

@etpinard
Copy link
Contributor

Thanks for the info @RichardNeill

I agree 0 and null should be treated differently here.

@RichardNeill
Copy link
Author

It's great that the bar now appears (as expected, a zero-height area, but with a thin non-zero border).

However, it's still not possible to see the tooltip - because the hover only works on the main area of a bar, and not over its border. (This is true for non-zero bars too). So it it possible to enable the hover tooltip when the mouse goes over a bar's border? Thanks

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

Successfully merging a pull request may close this issue.

4 participants