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

[BUG] Regression between 2.7.1 an 2.7.2 in bar charts with timescale #5844

Closed
nesnes opened this issue Nov 16, 2018 · 2 comments
Closed

[BUG] Regression between 2.7.1 an 2.7.2 in bar charts with timescale #5844

nesnes opened this issue Nov 16, 2018 · 2 comments

Comments

@nesnes
Copy link

nesnes commented Nov 16, 2018

No bar is displayed in 2.7.2+ version for a given data input.

Expected Behavior

Bar should be displayed (should be 1 bar per day in the example)

Current Behavior

The chart is empty

Possible Solution

Don't know, but it has something to do with the 2.7.2 bar-size feature.

Steps to Reproduce (for bugs)

  1. Open https://codepen.io/anon/pen/dQzPmB
  2. -> No bar will be displayed
  3. Set makeMeWork = true at the top of the JS
  4. -> Bar should be displayed like before the 2.7.2 bar-size feature.

Context

I'm no able to diplay a bar chart of the data I can see in a line chart

Notice

The data in the chart isn't sorted with a day interval, so the issue might just mean that I'm not using bars as I should. However, in this situation, it should generate "strange" bars, or provide a warning in the console.

@simonbrunel
Copy link
Member

I don't think it's a regression because the behavior of 2.7.1 was reported as a bug. But you are right, the new default bar sizing introduced in #4994 doesn't play well with your use case because it computes an "optimal" bar size applied to all bars (which is the smallest bar). The first issue is with scale.time.round: 'day' which "gathers" many values under the same time (label):

"labels": [                       // After round: 'day'
    "2018-11-05T11:04:37.865Z",   // "2018-11-05T00:00:00.000Z"  
    "2018-11-05T11:05:50.558Z",   // "2018-11-05T00:00:00.000Z"
    "2018-11-05T14:53:26.406Z",   // "2018-11-05T00:00:00.000Z"
    "2018-11-05T17:59:48.976Z",   // "2018-11-05T00:00:00.000Z"
    "2018-11-05T18:29:35.971Z",   // "2018-11-05T00:00:00.000Z"
    "2018-11-06T11:36:27.035Z",   // "2018-11-06T00:00:00.000Z"
    "2018-11-08T15:39:34.064Z",   // "2018-11-08T00:00:00.000Z"
    "2018-11-08T17:11:55.357Z",   // "2018-11-08T00:00:00.000Z"
    "2018-11-08T17:25:04.808Z",   // "2018-11-08T00:00:00.000Z"
]

For example, the distance between the first and second bar is 0 (applied to all bars), so that's why no bar is displayed. But removing the rounding doesn't fix your issue because you still have labels with very small interval (e.g. the 2 first ones are only ~1 minute) which generate very thin bar, almost invisible.

The solution depends on what you are expecting: if you want a similar result as of 2.7.1, you can use barThickness: 'flex'. You can also enforce a specific bar size (e.g. barThickness: 42) but it doesn't match well if your chart is responsive.

Though, I'm not sure your data are much compatible with the bar chart which tends to assume that bars of the same dataset must be side by side (i.e. don't overlap). Not sure how to interpret multiple values for the same day, for example 15, 19, 15, 15, 19 are all under "2018-11-05T00:00:00.000Z", how these values should be displayed?

@nesnes
Copy link
Author

nesnes commented Nov 16, 2018

I do agree that the issues come from my data input. I didn’t realized that the bar chart with a “day” round was expecting no more than 1 value per day (And it kinda makes sense). Should this generate a warning?

Also didn’t noticed the very thin bars, should a minWidth system exist that would be N by default and 0 to disable?

By the way, the whole library it pretty cool, and the only one out there that really does responsiveness a reality. Congrats to all.

@nesnes nesnes closed this as completed Dec 2, 2018
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

2 participants