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

Draw the rightmost grid line when offsetGridLines is true #6326

Merged
merged 5 commits into from Jul 18, 2019

Conversation

nagix
Copy link
Contributor

@nagix nagix commented Jun 8, 2019

With this PR, the rightmost grid line in bar charts, where offset and gridLines.offsetGridLines are true by default, will be drawn. It also fixes the following minor issue.

  • If gridLines.color is an array but some element is undefined, that line won't be drawn. It should rather be drawn in the default color.

I'm aware of #5480 trying to solve this by a new plugin, but there have been many changes in the core scale code since it was opened, and a lot of effort would be needed to rebase it. This PR doesn't prevent to introduce a separate grid line plugin, but proposes a simpler approach to address the issue based on the latest code base.

Master: https://jsfiddle.net/nagix/9ak5L48q/
Screen Shot 2019-06-08 at 10 54 57 PM

This PR: https://jsfiddle.net/nagix/dLv84ujs/
Screen Shot 2019-06-08 at 10 55 15 PM

Fixes #3804

@benmccann
Copy link
Contributor

benmccann commented Jun 8, 2019

I think #5480 is trying to do too much in a single PR. It'd be much easier to review if we added the new border functionality and separated the gridline functionality as a plugin in separate PRs, so I'm okay moving forward with this PR separately.

etimberg
etimberg previously approved these changes Jun 9, 2019
kurkle
kurkle previously approved these changes Jun 12, 2019
src/core/core.scale.js Outdated Show resolved Hide resolved
src/core/core.scale.js Outdated Show resolved Hide resolved
@nagix nagix dismissed stale reviews from kurkle and etimberg via 62442ff June 17, 2019 10:01
kurkle
kurkle previously approved these changes Jun 23, 2019
src/core/core.scale.js Show resolved Hide resolved
src/core/core.scale.js Outdated Show resolved Hide resolved
src/core/core.scale.js Outdated Show resolved Hide resolved
benmccann
benmccann previously approved these changes Jun 24, 2019
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.

lgtm.

I might consider splitting _computeItemsToDraw into _computeGridLineItems and _computeLabelItems as it's getting pretty big and it looks like there's essentially no shared code between them. It'd also mean you wouldn't need the extra variable anymore

@nagix
Copy link
Contributor Author

nagix commented Jun 26, 2019

@benmccann I like that idea. It will give some performance improvement if either grid lines or labels are hidden.

benmccann
benmccann previously approved these changes Jun 26, 2019
@benmccann
Copy link
Contributor

benmccann commented Jul 16, 2019

@nagix lgtm, but this PR will need to be rebased

etimberg
etimberg previously approved these changes Jul 16, 2019
@nagix
Copy link
Contributor Author

nagix commented Jul 17, 2019

Rebased

exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
* Draw the rightmost grid line when offsetGridLines is true

* Refactor based on feedback

* Replace helpers.each with for loop

* Minor refactoring

* Refactor _computeItemsToDraw
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.

[Possible Bug] Bar Chart doesn't display right border
4 participants