diff --git a/src/traces/parcoords/axisbrush.js b/src/traces/parcoords/axisbrush.js index e67c4c108e2..1e7cc8fcc65 100644 --- a/src/traces/parcoords/axisbrush.js +++ b/src/traces/parcoords/axisbrush.js @@ -78,6 +78,7 @@ function setHighlight(d) { if(!d.brush.filterSpecified) { return '0,' + d.height; } + var pixelRanges = unitToPx(d.brush.filter.getConsolidated(), d.height); var dashArray = [0]; // we start with a 0 length selection as filter ranges are inclusive, not exclusive var p, sectionHeight, iNext; @@ -102,7 +103,7 @@ function setHighlight(d) { function unitToPx(unitRanges, height) { return unitRanges.map(function(pr) { - return pr.map(function(v) { return v * height; }).sort(sortAsc); + return pr.map(function(v) { return Math.max(0, v * height); }).sort(sortAsc); }); } @@ -270,13 +271,6 @@ function attachDragBehavior(selection) { var topViolation = Math.max(0, s.newExtent[1] - 1); s.newExtent[0] += bottomViolation; s.newExtent[1] -= topViolation; - if(s.grabbingBar) { - // in case of bar dragging (non-resizing interaction, unlike north/south resize or new bar creation) - // the constraint adjustment must apply to the other end of the bar as well, otherwise it'd - // shorten or lengthen - s.newExtent[1] += bottomViolation; - s.newExtent[0] -= topViolation; - } d.brush.filterSpecified = true; s.extent = s.stayingIntervals.concat([s.newExtent]); diff --git a/test/image/baselines/gl2d_parcoords_out-of-range_selected-below.png b/test/image/baselines/gl2d_parcoords_out-of-range_selected-below.png new file mode 100644 index 00000000000..fb8c2e6902a Binary files /dev/null and b/test/image/baselines/gl2d_parcoords_out-of-range_selected-below.png differ diff --git a/test/image/mocks/gl2d_parcoords_out-of-range_selected-below.json b/test/image/mocks/gl2d_parcoords_out-of-range_selected-below.json new file mode 100644 index 00000000000..27f09936bfe --- /dev/null +++ b/test/image/mocks/gl2d_parcoords_out-of-range_selected-below.json @@ -0,0 +1,154 @@ +{ + "data": [ + { + "type": "parcoords", + "dimensions": [ + { + "label": "A+1", + "range": [ + 1, + 2 + ], + "constraintrange": [ + 1.25, + 1.75 + ], + "values": [ + 1, + 1.25, + 1.5, + 1.75, + 2 + ] + }, + { + "label": "2A", + "range": [ + 0, + 2 + ], + "constraintrange": [ + 0.5, + 1.5 + ], + "values": [ + 0, + 0.5, + 1, + 1.5, + 2 + ] + }, + { + "label": "A", + "range": [ + 0, + 1 + ], + "constraintrange": [ + 0.25, + 0.75 + ], + "values": [ + 0, + 0.25, + 0.5, + 0.75, + 1 + ] + }, + { + "label": "Above", + "range": [ + 0, + 1 + ], + "constraintrange": [ + 0.25, + 1.25 + ], + "values": [ + 0, + 0.25, + 0.5, + 0.75, + 1 + ] + }, + { + "label": "Below", + "range": [ + 0, + 1 + ], + "constraintrange": [ + -0.25, + 0.75 + ], + "values": [ + 0, + 0.25, + 0.5, + 0.75, + 1 + ] + }, + { + "label": "2/above", + "range": [ + 0, + 1 + ], + "constraintrange": [ + [ + 0.25, + 0.5 + ], + [ + 0.75, + 1.25 + ] + ], + "values": [ + 0, + 0.25, + 0.5, + 0.75, + 1 + ] + }, + { + "label": "2/below", + "range": [ + 0, + 1 + ], + "constraintrange": [ + [ + -0.25, + 0.25 + ], + [ + 0.5, + 0.75 + ] + ], + "values": [ + 0, + 0.25, + 0.5, + 0.75, + 1 + ] + } + ] + } + ], + "layout": { + "width": 600, + "height": 400, + "title": { + "text": "Should display & select constraintrange below/above ranges" + } + } +}