victory icon indicating copy to clipboard operation
victory copied to clipboard

[VictoryLine] When all values are the same, axis label become unreadable

Open CherishIt opened this issue 8 years ago • 3 comments

Bugs and Questions

Checklist

  • [x] This is not a victory-native specific issue. (Issues that only appear in victory-native should be opened here)

  • [x] I have read through the FAQ and Guides before asking a question

  • [x] I am using the latest version of Victory

  • [x] I've searched open issues to make sure I'm not opening a duplicate issue

The Problem

When all values of y are 0, axis labels become unreadable and x axis move to the center of chart.

Reproduction

https://codesandbox.io/s/yjk6x2mnxv

Expected behavior

Axis should have valid domain for special cases, and axis should be at static position. For example, if all 0, axis domain -> [0,1], if some value other than 0, axis domain => [0, value]

CherishIt avatar Dec 22 '17 07:12 CherishIt

@CherishIt this expected default behavior for Victory. By default, the domain is calculated from data. When only a single value exists, Victory will pad that value with a very small number to prevent errors, and to center data. If you want to change this default behavior, you can add a domain manually like so: https://codesandbox.io/s/ym97jo70p1

boygirl avatar Dec 28 '17 19:12 boygirl

@boygirl I've just been stung by this bug as well. I'm creating a graph that tracks events per minute for the last x minutes. It's entirely valid that my graph can be empty - but I don't see how it's valid to suggest that a developer override the domain in the situation where the graph is empty, just to avoid showing the 'very small number' on your axis.

If setting a 'very small number' as the maxDomain is just to avoid errors, why not set it to a sensible default e.g. 1 as suggested in this issue? Or at the very least, this behaviour should be documented somewhere e.g. in the FAQ, as it took me a while to find this issue.

benco03 avatar Jun 28 '18 09:06 benco03

@benco03 I'm sorry this gave you a hard time. Unfortunately setting a [0, 1] domain as a default is not sensible for all user data. In fact, no set default domain can cover all cases, which is why we choose to pad single values with verySmallNumber instead. The documentation could definitely be improved. I will open an issue in our victory-docs repo.

boygirl avatar Jun 28 '18 18:06 boygirl