Skip to content

Commit b52e990

Browse files
authored
Merge pull request #4660 from plotly/remove-rangebreaks-operation
Revise operation in rangebreaks
2 parents 747be93 + c4dde70 commit b52e990

16 files changed

+83
-273
lines changed

src/plots/cartesian/axis_defaults.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,5 @@ function rangebreaksDefaults(itemIn, itemOut, containerOut) {
187187
return;
188188
}
189189
}
190-
191-
coerce('operation');
192190
}
193191
}

src/plots/cartesian/layout_attributes.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ module.exports = {
273273
editType: 'calc',
274274
description: [
275275
'Sets the lower and upper bounds of this axis rangebreak.',
276-
'Can be used with `operation` to determine the behavior at the bounds.',
277276
'Can be used with `pattern`.'
278277
].join(' ')
279278
},
@@ -292,7 +291,7 @@ module.exports = {
292291
'Examples:',
293292
'- { pattern: \'' + DAY_OF_WEEK + '\', bounds: [6, 0] }',
294293
' breaks from Saturday to Monday (i.e. skips the weekends).',
295-
'- { pattern: \'' + HOUR + '\', bounds: [17, 8], operation: \'()\' }', // TODO: simplify after revise defaults
294+
'- { pattern: \'' + HOUR + '\', bounds: [17, 8] }',
296295
' breaks from 5pm to 8am (i.e. skips non-work hours).'
297296
].join(' ')
298297
},
@@ -325,23 +324,6 @@ module.exports = {
325324
].join(' ')
326325
},
327326

328-
operation: {
329-
valType: 'enumerated',
330-
values: ['[]', '()', '[)', '(]'],
331-
dflt: '[]',
332-
role: 'info',
333-
editType: 'calc',
334-
description: [
335-
'Determines if we include or not the bound values within the rangebreak.',
336-
'Closed interval bounds (i.e. starting with *[* or ending with *]*)',
337-
'include the bound value within the rangebreak and thus make coordinates',
338-
'equal to the bound disappear.',
339-
'Open interval bounds (i.e. starting with *(* or ending with *)*)',
340-
'does not include the bound value within the rangebreak and thus keep coordinates',
341-
'equal to the bound on the axis.'
342-
].join(' ')
343-
},
344-
345327
/*
346328
gap: {
347329
valType: 'number',

src/plots/cartesian/set_convert.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,6 @@ module.exports = function setConvert(ax, fullLayout) {
620620
var brk = rangebreaksIn[i];
621621

622622
if(brk.enabled) {
623-
var op = brk.operation;
624-
var op0 = op.charAt(0);
625-
var op1 = op.charAt(1);
626-
627623
if(brk.bounds) {
628624
var pattern = brk.pattern;
629625
bnds = Lib.simpleMap(brk.bounds, pattern ?
@@ -671,24 +667,13 @@ module.exports = function setConvert(ax, fullLayout) {
671667
break;
672668
}
673669

674-
if(
675-
(op0 === '(' ? vb > b0 : vb >= b0) &&
676-
(op1 === ')' ? vb < b1 : vb <= b1)
677-
) return BADNUM;
670+
if(vb >= b0 && vb < b1) return BADNUM;
678671
} else {
679672
var vals = Lib.simpleMap(brk.values, ax.d2c).sort(Lib.sorterAsc);
680-
var onOpenBound = false;
681-
682673
for(var j = 0; j < vals.length; j++) {
683674
b0 = vals[j];
684675
b1 = b0 + brk.dvalue;
685-
if(
686-
(op0 === '(' ? v > b0 : v >= b0) &&
687-
(op1 === ')' ? v < b1 : v <= b1)
688-
) return BADNUM;
689-
690-
if(onOpenBound && op0 === '(' && v === b0) return BADNUM;
691-
onOpenBound = op1 === ')' && v === b1;
676+
if(v >= b0 && v < b1) return BADNUM;
692677
}
693678
}
694679
}
@@ -737,14 +722,9 @@ module.exports = function setConvert(ax, fullLayout) {
737722
var brk = rangebreaksIn[i];
738723

739724
if(brk.enabled) {
740-
var op = brk.operation;
741-
var op0 = op.charAt(0);
742-
var op1 = op.charAt(1);
743-
744725
if(brk.bounds) {
745726
if(brk.pattern) {
746727
bnds = Lib.simpleMap(brk.bounds, cleanNumber);
747-
if(bnds[0] === bnds[1] && op === '()') continue;
748728

749729
// r0 value as date
750730
var r0Date = new Date(r0);
@@ -761,12 +741,11 @@ module.exports = function setConvert(ax, fullLayout) {
761741

762742
switch(brk.pattern) {
763743
case WEEKDAY_PATTERN:
764-
b0 = bnds[0] + (op0 === '(' ? 1 : 0);
744+
b0 = bnds[0];
765745
b1 = bnds[1];
766746
r0Pattern = r0Date.getUTCDay();
767747
r0PatternDelta = b0 - r0Pattern;
768748
bndDelta = (b1 >= b0 ? b1 - b0 : (b1 + 7) - b0) * ONEDAY;
769-
if(op1 === ']') bndDelta += ONEDAY;
770749
step = 7 * ONEDAY;
771750

772751
t = r0 + r0PatternDelta * ONEDAY -
-26.4 KB
Binary file not shown.
3.54 KB
Loading
-276 Bytes
Loading
Loading

test/image/mocks/axes_breaks-bars.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/image/mocks/axes_breaks-finance.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,10 @@
364364
"rangebreaks": [
365365
{
366366
"pattern": "day of week",
367-
"bounds": [ 6, 0 ]
367+
"bounds": [ 6, 1 ]
368368
},
369369
{
370-
"values": ["2017-01-16"],
371-
"operation": "()"
370+
"values": ["2017-01-16"]
372371
}
373372
]
374373
},
@@ -377,11 +376,10 @@
377376
"rangebreaks": [
378377
{
379378
"pattern": "day of week",
380-
"bounds": [ 6, 0 ]
379+
"bounds": [ 6, 1 ]
381380
},
382381
{
383-
"values": ["2017-01-16"],
384-
"operation": "()"
382+
"values": ["2017-01-16"]
385383
}
386384
]
387385
},

test/image/mocks/axes_breaks-night_autorange-reversed.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@
196196
"bounds": [
197197
18,
198198
6
199-
],
200-
"operation": "[)"
199+
]
201200
}
202201
],
203202
"domain": [
@@ -212,8 +211,7 @@
212211
"bounds": [
213212
18,
214213
6
215-
],
216-
"operation": "[)"
214+
]
217215
}
218216
],
219217
"autorange": "reversed",
@@ -257,8 +255,7 @@
257255
"bounds": [
258256
18,
259257
6
260-
],
261-
"operation": "[)"
258+
]
262259
}
263260
],
264261
"anchor": "x3",
@@ -274,8 +271,7 @@
274271
"bounds": [
275272
18,
276273
6
277-
],
278-
"operation": "[)"
274+
]
279275
}
280276
],
281277
"autorange": "reversed",

test/image/mocks/axes_breaks-rangeslider.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,23 +2655,19 @@
26552655
"rangebreaks": [
26562656
{
26572657
"pattern": "day of week",
2658-
"bounds": [6, 0],
2659-
"operation": "[]"
2658+
"bounds": [6, 1]
26602659
},
26612660
{
26622661
"pattern": "hour",
2663-
"bounds": [0, 9],
2664-
"operation": "()"
2662+
"bounds": [0, 9]
26652663
},
26662664
{
26672665
"pattern": "hour",
2668-
"bounds": [12, 13],
2669-
"operation": "()"
2666+
"bounds": [12, 13]
26702667
},
26712668
{
26722669
"pattern": "hour",
2673-
"bounds": [15, 21],
2674-
"operation": "()"
2670+
"bounds": [15, 21]
26752671
}
26762672
],
26772673
"rangeslider": { "visible": true }

test/image/mocks/axes_breaks-tickvals.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
{"bounds": [
2121
"1969-12-31 23:59:59.999",
2222
"1970-01-01 00:00:00.090"
23-
], "operation": "()"},
23+
]},
2424
{"bounds": [
2525
"1970-01-01 00:00:00.101",
2626
"1970-01-01 00:00:00.189"
27-
], "operation": "()"}
27+
]}
2828
],
2929
"tickvals": [
3030
"1969-12-31 23:59:59.980",

test/image/mocks/axes_breaks-values.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"layout": {
1515
"xaxis": {
1616
"rangebreaks": [
17-
{ "values": [ "2020-01-04", "2020-01-05" ], "operation": "()" }
17+
{ "values": [ "2020-01-03 23:59:59", "2020-01-05" ] }
1818
]
1919
}
2020
}

test/image/mocks/axes_breaks-weekends-weeknights.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
"rangebreaks": [
1717
{
1818
"pattern": "day of week",
19-
"bounds": [ 6, 0 ],
20-
"operation": "[]"
19+
"bounds": [ 6, 1 ]
2120
},
2221
{
2322
"pattern": "hour",
24-
"bounds": [ 16, 8 ],
25-
"operation": "()"
23+
"bounds": [ 16.001, 8 ]
2624
}
2725
]
2826
},

test/image/mocks/axes_breaks-weekends_autorange-reversed.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@
9191
"pattern": "day of week",
9292
"bounds": [
9393
6,
94-
0
95-
],
96-
"operation": "[]"
94+
1
95+
]
9796
}
9897
],
9998
"domain": [
@@ -107,9 +106,8 @@
107106
"pattern": "day of week",
108107
"bounds": [
109108
6,
110-
0
111-
],
112-
"operation": "[]"
109+
1
110+
]
113111
}
114112
],
115113
"autorange": "reversed",
@@ -152,9 +150,8 @@
152150
"pattern": "day of week",
153151
"bounds": [
154152
6,
155-
0
156-
],
157-
"operation": "[]"
153+
1
154+
]
158155
}
159156
],
160157
"anchor": "x3",
@@ -169,9 +166,8 @@
169166
"pattern": "day of week",
170167
"bounds": [
171168
6,
172-
0
173-
],
174-
"operation": "[]"
169+
1
170+
]
175171
}
176172
],
177173
"autorange": "reversed",

0 commit comments

Comments
 (0)