-
-
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
Introduce cartesian axis breaks #4614
Conversation
... including potential future attributes `gap` and `gapmode`
- used during makeCalcdata to mask (i.e. set to BADNUM) coordinates inside the axis breaks.
- add abstractions: + ax._breaks, the disjoint breaks inside the range though ax.locateBreaks + ax._lBreaks, length of these breaks in value space + ax._m2, l2p slope (same for all intervals) + ax._B, set of l2p offsets (one for each of the (N+1) piecewise intervals) - adapt l2p and p2l for axis breaks - add jasmine tests for setConvert and hover labels
... as the value-space length is reduced when axis breaks are present within the trial range
- reduce the value-space range by `ax._lBreaks` to get the correct the number of auto ticks on the axes. - add logic to remove ticks falling inside breaks - add (could do better) logic for ticks that overlap on either side of a break.
- test breaks on x axes - test breaks on y axes - test date axes with patterns - test breaks with tickvals and ticktext - test for zeroline inside breaks
itemOut.enabled = false; | ||
return; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about handling autorange: 'reversed'
case?
In the following demos I tried to flip the axes which it didn't work.
https://codepen.io/MojtabaSamimi/pen/yLNzLra?editors=0010
https://codepen.io/MojtabaSamimi/pen/bGdoGyG?editors=0010
https://codepen.io/MojtabaSamimi/pen/QWbqWRj?editors=0010
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I forgot to test those. They won't be handled here as this logic has to do with set (i.e. autorange: false
) ranges, but yeah I'll get this fixed. Thanks!
break; | ||
} | ||
|
||
while(t <= r1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a finite test for t
before entring this loop?
Is there any scenario (e.g. on reversed axes) in which step could be negative?
Looks great! Do we have any control over the visual aspect of the break? Can we put in a gap or a squiggle or something? |
Not at the moment. plotly.js/src/plots/cartesian/layout_attributes.js Lines 346 to 375 in 187c93a
|
OK. I feel like introducing breaks without visible gaps is a bit scary in other contexts than "drop weekends for business metrics" ... what's the LOE on visible gaps? |
Probably 1-2 days for gaps w/o squiggle on the axis. I suspect that getting everyone happy with the squiggle look/behaviour will take a few days on its own. |
- pass axis breaks to mock rangeslider figures - consider axis breaks in rangeslider d2p & p2d - add mocks + drag test
... that way, positions that include some sort of offset (e.g. bar x0/x1, ohlc xo/xc) have the adequate px position.
To capture what was discussed today: for 1.53 let's activate this feature for date axes only please. We'll need to think about axis gap and bar charts etc before turning this on on linear/log axes I think. |
TODO:
see comments over on: axis-breaks...axis-breaks-fixups @archmoj will attempt to fix these tomorrow and on Monday the 9th.
I should be able to look at these when I get back Tuesday the 10th. |
- this will be dealt with in #4630
Improved once more in 1b55b42 Pan fixes from @archmoj are in 40d57fa
Done in 49b4053 |
Great PR! Thanks very much @etpinard for tackling all this. |
Ok, merging to get a first round of QA rolling (I suspect a few bug reports will come out of it). Updated examples: breaks using pattern on date axis: https://codepen.io/etpinard/pen/PoqRNoL |
🏆 thanks @etpinard 🙇 |
Is this functionality part of any release? Or is it still experimental? I'm having a little trouble finding how to do it in the docs. |
@kenahoo yes it is available since |
which presents a solution for removing weekends, holidays and non-work hours as requested in #1382 and lays the groundwork from "visually skipped" ranges as in the screenshot in #4210.
In brief, this PR adds a
breaks
array attribute to cartesian axes. Each item inside breaks defines an axis break either using a 2-itembounds
array or a free-length array ofvalues
. When usingbounds
on date axes, one can set a pattern to generate breaks e.g. over all weekends or non-work hours. When usingvalues
, one can set the "spread" of each value usingdvalue
. The inclusive/exclusive behaviour at the bounds is determined by theoperation
attributes (as used in filter transforms).Some examples:
pattern
on date axis: https://codepen.io/etpinard/pen/MWwvGBV?editors=1010values
on date axis: https://codepen.io/etpinard/pen/PoqKedGTo implement axis
breaks
,BADNUM
(more info in baf753a). Please note that this implies that lines remain continuous across a break if there's no (x,y) pt inside the break in question.ax.setScale
(i.e. when the range is known) and adapt thel2p
andp2l
mappings (more info in 259eafa)range[1] - range[0]
) for autorange padding, ticks placement computations and during drag interactions.cc @archmoj @alexcjohnson @nicolaskruchten @antoinerg