Skip to content

Implement layout.barbase (closes issue 475) #2

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

Closed
wants to merge 13 commits into from

Conversation

n-riesco
Copy link
Owner

I'm working on issues plotly#475 and plotly#80 . Both require changes in set_positions.js. For this reason, this PR not only implements layout.barbase (issue plotly#475), but also refactors the code in set_positions.js into functions for each layout.barmode. This change will help me with the next PR to implement issue plotly#80.

I think it's best to review each commit separately.

* Simplified algorithm to identify overlapping bars.

* Removed the closure setBarCenter.

* Checked that jasmine tests still pass.
* Converted the closure that groups vertical and horizontal bars into a
  function.

* This change will help split setPositions into functions for each
  barmode.
* Moved code to group bars from setGroupPositions to setPositions.
* Converted closure `barpositions` into function `setOffsetAndWidth`.

* This change will help split setPositions into functions for each
  barmode.
* Don't assume the position axis is `xa` in the calculation of
  `barDelta` in `bar/hover.js`.

* Updated `tests/bar_test.js` to account for the replacement of `t.bar`
  with `t.bargroupwidth`.

* Updated the group case in `tests/bar_test.js` to test the use of
  `layout.bargroupgap`.
* Refactored the code to set bar positions in overlay mode into function
  `setGroupPositionsInOverlayMode`.
* Refactored the code for setting bar positions into
  setGroupPositionsInOverlayMode,
  setGroupPositionsInGroupMode and
  setGroupPositionsInStackOrRelativeMode.

* Refactored code for stacking bars and computing minDiff into helper
  class Sieve.
* Renamed setBaseAndSize to stackBars.

* Refactor code to normalize bars into function normalizeBars.
* Fix: do not normalise bars with no size

* Fix: update minDtick if barmode is group and bars overlap.

Closes plotly#475
@etpinard
Copy link

@n-riesco your refactoring commits are looking good. 🎉 Thanks! bar/set_positions is very clear and readable. Looks like your sieve implementation is a lot more robust than what we had previously.

I apologise again for the barbase confusion. As we discussed on slack, layout-wide bar-base setting isn't worth adding to the library. I propose rebasing without your last three commits and making a refactor-only PR and then move on to plotly#80.

I'm a little concerned about merging this in though as bar is a very ancient trace type which is tested almost exclusively via image tests. I would love to see a few more edge cases tested in bar_test.js calc / setPositions suite.

Thanks again for your hard work.

@n-riesco n-riesco closed this Oct 27, 2016
@n-riesco n-riesco deleted the 20161006-issue-475-barbase branch October 27, 2016 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants