Skip to content

Commit 6d09846

Browse files
authored
Merge pull request #4083 from plotly/phx240-constraint-below-range
Parcoords bug fix - do not draw full select line when constraint range falls below range
2 parents 92fc203 + 65ea8e6 commit 6d09846

File tree

3 files changed

+156
-8
lines changed

3 files changed

+156
-8
lines changed

src/traces/parcoords/axisbrush.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function setHighlight(d) {
7878
if(!d.brush.filterSpecified) {
7979
return '0,' + d.height;
8080
}
81+
8182
var pixelRanges = unitToPx(d.brush.filter.getConsolidated(), d.height);
8283
var dashArray = [0]; // we start with a 0 length selection as filter ranges are inclusive, not exclusive
8384
var p, sectionHeight, iNext;
@@ -102,7 +103,7 @@ function setHighlight(d) {
102103

103104
function unitToPx(unitRanges, height) {
104105
return unitRanges.map(function(pr) {
105-
return pr.map(function(v) { return v * height; }).sort(sortAsc);
106+
return pr.map(function(v) { return Math.max(0, v * height); }).sort(sortAsc);
106107
});
107108
}
108109

@@ -270,13 +271,6 @@ function attachDragBehavior(selection) {
270271
var topViolation = Math.max(0, s.newExtent[1] - 1);
271272
s.newExtent[0] += bottomViolation;
272273
s.newExtent[1] -= topViolation;
273-
if(s.grabbingBar) {
274-
// in case of bar dragging (non-resizing interaction, unlike north/south resize or new bar creation)
275-
// the constraint adjustment must apply to the other end of the bar as well, otherwise it'd
276-
// shorten or lengthen
277-
s.newExtent[1] += bottomViolation;
278-
s.newExtent[0] -= topViolation;
279-
}
280274

281275
d.brush.filterSpecified = true;
282276
s.extent = s.stayingIntervals.concat([s.newExtent]);
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"data": [
3+
{
4+
"type": "parcoords",
5+
"dimensions": [
6+
{
7+
"label": "A+1",
8+
"range": [
9+
1,
10+
2
11+
],
12+
"constraintrange": [
13+
1.25,
14+
1.75
15+
],
16+
"values": [
17+
1,
18+
1.25,
19+
1.5,
20+
1.75,
21+
2
22+
]
23+
},
24+
{
25+
"label": "2A",
26+
"range": [
27+
0,
28+
2
29+
],
30+
"constraintrange": [
31+
0.5,
32+
1.5
33+
],
34+
"values": [
35+
0,
36+
0.5,
37+
1,
38+
1.5,
39+
2
40+
]
41+
},
42+
{
43+
"label": "A",
44+
"range": [
45+
0,
46+
1
47+
],
48+
"constraintrange": [
49+
0.25,
50+
0.75
51+
],
52+
"values": [
53+
0,
54+
0.25,
55+
0.5,
56+
0.75,
57+
1
58+
]
59+
},
60+
{
61+
"label": "Above",
62+
"range": [
63+
0,
64+
1
65+
],
66+
"constraintrange": [
67+
0.25,
68+
1.25
69+
],
70+
"values": [
71+
0,
72+
0.25,
73+
0.5,
74+
0.75,
75+
1
76+
]
77+
},
78+
{
79+
"label": "Below",
80+
"range": [
81+
0,
82+
1
83+
],
84+
"constraintrange": [
85+
-0.25,
86+
0.75
87+
],
88+
"values": [
89+
0,
90+
0.25,
91+
0.5,
92+
0.75,
93+
1
94+
]
95+
},
96+
{
97+
"label": "2/above",
98+
"range": [
99+
0,
100+
1
101+
],
102+
"constraintrange": [
103+
[
104+
0.25,
105+
0.5
106+
],
107+
[
108+
0.75,
109+
1.25
110+
]
111+
],
112+
"values": [
113+
0,
114+
0.25,
115+
0.5,
116+
0.75,
117+
1
118+
]
119+
},
120+
{
121+
"label": "2/below",
122+
"range": [
123+
0,
124+
1
125+
],
126+
"constraintrange": [
127+
[
128+
-0.25,
129+
0.25
130+
],
131+
[
132+
0.5,
133+
0.75
134+
]
135+
],
136+
"values": [
137+
0,
138+
0.25,
139+
0.5,
140+
0.75,
141+
1
142+
]
143+
}
144+
]
145+
}
146+
],
147+
"layout": {
148+
"width": 600,
149+
"height": 400,
150+
"title": {
151+
"text": "Should display & select constraintrange below/above ranges"
152+
}
153+
}
154+
}

0 commit comments

Comments
 (0)