Browse Source

HUE-2679 [search] Re-enable timeline refresh and brush toggle

Enrico Berti 10 years ago
parent
commit
ed9798177c

+ 18 - 0
desktop/core/src/desktop/static/desktop/js/ko.charts.js

@@ -201,6 +201,7 @@ ko.bindingHandlers.timelineChart = {
     }
   },
   update: function (element, valueAccessor) {
+    var _options = valueAccessor();
     if (valueAccessor().type && valueAccessor().type() != $(element).data("type")){
       if ($(element).find("svg").length > 0) {
         $(element).find("svg").remove();
@@ -213,6 +214,23 @@ ko.bindingHandlers.timelineChart = {
       }
       $(element).data("type", valueAccessor().type());
     }
+    var _datum = _options.transformer(_options.datum);
+    var _chart = $(element).data("chart");
+    if (_chart) {
+      var _d3 = d3.select($(element).find("svg")[0]);
+      _d3.datum(_datum)
+          .transition().duration(150)
+          .each("end", function () {
+            if (_options.onComplete != null) {
+              _options.onComplete();
+            }
+          }).call(_chart);
+        _d3.selectAll("g.nv-x.nv-axis g text").each(function (d){
+          insertLinebreaks(d, this);
+        });
+        //_d3.selectAll('.nv-brush').attr('display', 'none');
+        _d3.selectAll(".nv-brush").call(_chart.brush().clear());
+    }
   }
 };
 

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

@@ -626,6 +626,12 @@ nv.models.lineWithBrushChart = function() {
     return chart;
   };
 
+  chart.brush = function(_) {
+    if (!arguments.length) return brush;
+    brush = _;
+    return chart;
+  };
+
   //============================================================
 
 

+ 6 - 0
desktop/core/src/desktop/static/desktop/js/nv.d3.multiBarWithBrushChart.js

@@ -690,6 +690,12 @@ nv.models.multiBarWithBrushChart = function() {
     return chart;
   };
 
+  chart.brush = function(_) {
+    if (!arguments.length) return brush;
+    brush = _;
+    return chart;
+  };
+
 
   //============================================================