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

Fix a bar overlap issue with unordered labels #4674

Closed
wants to merge 2 commits into from

Conversation

nagix
Copy link
Contributor

@nagix nagix commented Aug 17, 2017

When a time scale is used and labels or datasets for bars are unordered, bars will overlap each other. This PR fixes the issue by sorting bar positions when creating the ruler.

Current version: https://jsfiddle.net/msL6xL83/
Proposed version: https://jsfiddle.net/xdajx1mb/

@simonbrunel
Copy link
Member

@nagix your jsfiddle don't work for me, I think that's because of raw.githubusercontent.com (error: Github is not a CDN). Maybe you can try with https://rawgit.com/ instead?

@nagix
Copy link
Contributor Author

nagix commented Aug 18, 2017

@simonbrunel I replaced the links with https://rawgit.com/. Do they work?

@etimberg
Copy link
Member

@nagix the fiddles work now! I like the results

});
for (i = 0, ilen = pixels.length; i < ilen; ++i) {
orderedPixels.push(pixels[i].value);
order[pixels[i].index] = i;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this index translation. I feel like we should sort the data at the beginning but that has a number of downsides. It changes the data the user specified and also requires adjusting the data arrays in each dataset accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to adjust the data arrays in datasets because the order array translates an original index into an ordered index, and the ordered indexes and pixels are only used for bar width calculation. Do you have any specific problematic cases in mind?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problematic cases are mostly for debugging purposes. It's mostly code style / personal preference. But i will agree that this is the simplest way to achieve this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added comments to avoid confusions in the future.

@simonbrunel
Copy link
Member

Just want to be sure we want to handle that special case since it requires iterating the data 3 times (instead of only 1) and deal with index translation / intermediate structure, and I feel that most of the time the data are in the correct order?

Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonbrunel I agree. I think the user typically passes in data in the correct order

I'd prefer adding a check to ensure a strict ordering. This would not require iterating the data an extra time and would result in simpler code

@etimberg
Copy link
Member

Closing due to inactivity

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

Successfully merging this pull request may close these issues.

5 participants