Skip to content

Commit

Permalink
refactor long lines - move bounds set out of switch
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Mar 27, 2020
1 parent 0359a8e commit 0d6d798
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/plots/cartesian/set_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ module.exports = function setConvert(ax, fullLayout) {
if(brk.bounds) {
if(brk.pattern) {
bnds = Lib.simpleMap(brk.bounds, cleanNumber);
b0 = bnds[0];
b1 = bnds[1];

// r0 value as date
var r0Date = new Date(r0);
Expand All @@ -739,9 +741,10 @@ module.exports = function setConvert(ax, fullLayout) {
case WEEKDAY_PATTERN:
step = 7 * ONEDAY;

b0 = bnds[0];
b1 = bnds[1];
bndDelta = (b1 < b0 ? 7 : 0) * ONEDAY + (b1 - b0) * ONEDAY;
bndDelta = (
(b1 < b0 ? 7 : 0) +
(b1 - b0)
) * ONEDAY;

t = r0 + b0 * ONEDAY - (
r0Date.getUTCDay() * ONEDAY +
Expand All @@ -754,9 +757,10 @@ module.exports = function setConvert(ax, fullLayout) {
case HOUR_PATTERN:
step = ONEDAY;

b0 = bnds[0];
b1 = bnds[1];
bndDelta = (b1 < b0 ? 24 : 0) * ONEHOUR + (b1 - b0) * ONEHOUR;
bndDelta = (
(b1 < b0 ? 24 : 0) +
(b1 - b0)
) * ONEHOUR;

t = r0 + b0 * ONEHOUR - (
r0Date.getUTCHours() * ONEHOUR +
Expand Down

0 comments on commit 0d6d798

Please sign in to comment.