Browse Source

HUE-2679 [search] Fix problem with always selected bars and slices

Enrico Berti 10 years ago
parent
commit
51f147afdb

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

@@ -229,6 +229,25 @@ ko.bindingHandlers.timelineChart = {
         insertLinebreaks(d, this);
       });
       _d3.selectAll(".nv-brush").call(_chart.brush().clear());
+      if (_chart.selectBars) {
+        $.each(_options.fqs(), function (cnt, item) {
+          if (item.id() == _options.datum.widget_id) {
+            if (item.field() == _options.field) {
+              _chart.selectBars($.map(item.filter(), function (it) {
+                return it.value();
+              }));
+            }
+            if (item.field().indexOf(":") > -1) {
+              _chart.selectBars({
+                field: item.field(),
+                selected: $.map(item.filter(), function (it) {
+                  return it.value();
+                })
+              });
+            }
+          }
+        });
+      }
       chartsNormalState();
     }
   }

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

@@ -134,7 +134,7 @@ nv.models.growingDiscreteBar = function() {
 
 
       var bars = groups.selectAll('g.nv-bar')
-          .data(function(d) { return d.values });
+          .data(function(d) { return d.values }).classed('selected', false);
 
       bars.exit().remove();
 

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

@@ -201,7 +201,7 @@ nv.models.growingMultiBar = function() {
 
 
       var bars = groups.selectAll('rect.nv-bar')
-          .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values });
+          .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values }).classed('selected', false);
 
       bars.exit().remove();
 

+ 2 - 1
desktop/core/src/desktop/static/desktop/js/nv.d3.growingPie.js

@@ -101,7 +101,7 @@ nv.models.growingPie = function() {
           .value(function(d) { return d.disabled ? 0 : getY(d) });
 
       var slices = wrap.select('.nv-pie').selectAll('.nv-slice')
-          .data(pie);
+          .data(pie).classed('selected', false);
 
       var pieLabels = wrap.select('.nv-pieLabels').selectAll('.nv-label')
           .data(pie);
@@ -109,6 +109,7 @@ nv.models.growingPie = function() {
       slices.exit().remove();
       pieLabels.exit().remove();
 
+
       selectSlices = function(selected) {
         $(selected).each(function(cnt, item){
           slices.each(function(d, i) {