-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implement attributes base, offset and width in bar traces (issue 80) #1075
Implement attributes base, offset and width in bar traces (issue 80) #1075
Conversation
* 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.
* Allow minDtick update if barmode is group and bars overlap.
* Function sieveBars sieves all the bars without updating the bar bases. This step is required before calling normalizeBars. * Function stackBars sieves all the bars and updates the bar bases and tops accordingly.
* Null defaults are used to denote optional properties. * Note that null values are ignored by `Lib.nestedProperty(/**/).set()`, so that the pattern `fullTrace.base === undefined` still works.
* Added note to explain the reason why setGroupPositionsInOverlayMode handles the case barnorm is defined.
* Moved shared code between `setOffsetAndWidth` and `setOffsetAndWidthInGroupMode` to handle offset and width attributes into function `applyAttributes`.
* Test the use of the bar attributes: base, offset and width.
* Added mock images of bar plots using the attributes base, offset and width.
@n-riesco great. I'll give this PR one last test drive tomorrow morning (UTC-4) |
* This change is needed so that the attribute `base` in bar traces can accept `number` and `Date` values.
I guess the easiest workaround would be to use |
Can If so, then it should be |
In principle, @alexcjohnson How do you think? Did you have anything in mind in #80 that would require |
In general if there's no concept of zero on an axis then bar charts don't make sense. Though interestingly I guess with |
@etpinard @alexcjohnson Here's a crazy idea. At the moment, plotly classifies as |
Hmm. I afraid that patching So, let's go with Thanks for the heads-up @n-riesco ! |
I wonder if there would be value in valType unions, so you could specify number or date string, for example. |
yes please. |
Oh @n-riesco I forgot about something ... We (unfortunately - see #648) need to manually list which attributes require going through the calc / set-position on updates. That list is getting really ugly, but luckily the patch is easy to make: should be all you need. While doing so, maybe you can add one Sorry about the late notice. |
* Fixed the bar tests that make use of the attribute offset. The values of the bar center in these tests were incorrect.
* Refactored `setWidthAndOffset` and `setWidthAndOffsetInGroupMode` so that the bar center is computed after applying the trace attributes offset and width.
@etpinard While writing the |
@n-riesco you win the PR of week 🏆 Thanks very much. This should make a bunch of people 😄 |
This PR implements attributes base, offset and width as discussed in #80 .
This PR's review can be found here.