Browse Source

HUE-8178 [charts] Remove gray section when zooming.

jdesjean 7 years ago
parent
commit
158136fa2d

+ 6 - 1
desktop/core/src/desktop/static/desktop/js/nv.d3.lineWithBrushChart.js

@@ -347,7 +347,12 @@ nv.models.lineWithBrushChart = function() {
           .on('brushend', onBrushEnd);
           .on('brushend', onBrushEnd);
         if (chart.brushDomain) {
         if (chart.brushDomain) {
           var brushExtent = [fGetNumericValue(chart.brushDomain[0]), fGetNumericValue(chart.brushDomain[1])];
           var brushExtent = [fGetNumericValue(chart.brushDomain[0]), fGetNumericValue(chart.brushDomain[1])];
-          brush.extent(brushExtent);
+          var isWholeDomain =  xAxis.scale()(chart.brushDomain[0]) < 10 && xAxis.scale()(chart.brushDomain[1]) >= xAxis.range()[1];
+          if (!isWholeDomain) { // If brush is the whole domain, don't display brush
+            brush.extent(brushExtent);
+          } else {
+            brush.clear();
+          }
         } else {
         } else {
           brush.clear();
           brush.clear();
         }
         }

+ 8 - 3
desktop/core/src/desktop/static/desktop/js/nv.d3.multiBarWithBrushChart.js

@@ -371,8 +371,12 @@ nv.models.multiBarWithBrushChart = function() {
           .on('brushstart', onBrushStart)
           .on('brushstart', onBrushStart)
           .on('brushend', onBrushEnd);
           .on('brushend', onBrushEnd);
         if (chart.brushDomain) {
         if (chart.brushDomain) {
-          var brushExtent = fromSelection(chart.brushDomain).range;
-          brush.extent(brushExtent);
+          var selection = fromSelection(chart.brushDomain);
+          if (!selection.isWholeDomain) { // If brush is the whole domain, don't display brush
+            brush.extent(fromSelection(chart.brushDomain).range);
+          } else {
+            brush.clear();
+          }
         } else {
         } else {
           brush.clear();
           brush.clear();
         }
         }
@@ -662,7 +666,8 @@ nv.models.multiBarWithBrushChart = function() {
         }
         }
         var _toRange = x.range()[_j] != undefined ? x.range()[_j] : x.range()[_leftEdges.length - 1] + _width;
         var _toRange = x.range()[_j] != undefined ? x.range()[_j] : x.range()[_leftEdges.length - 1] + _width;
         return {
         return {
-          range: [_fromRange, _fromRange === _toRange ? _fromRange + x.rangeBand() : _toRange]
+          range: [_fromRange, _fromRange === _toRange ? _fromRange + x.rangeBand() : _toRange],
+          isWholeDomain: selection[0] <= _leftEdges[0] && selection[1] >= _leftEdges[_leftEdges.length - 1]
         };
         };
       }
       }
       function onMouseMove () {
       function onMouseMove () {