Browse Source

[search] Zoomable property on partition chart and fixed logGA bug

Enrico Berti 11 years ago
parent
commit
0125266148

+ 1 - 0
apps/search/src/search/templates/search.mako

@@ -875,6 +875,7 @@ ${ dashboard.layout_skeleton() }
         <div data-bind="partitionChart: {datum: {counts: $parent.count, widget_id: id(), label: $parent.label},
           fqs: $root.query.fqs,
           transformer: partitionChartDataTransformer,
+          zoomable: false,
           onStateChange: function(state){ },
           onClick: function(d) {
             $root.query.togglePivotFacet({facet: d.obj, widget_id: id()});

+ 6 - 5
apps/search/static/js/search.ko.js

@@ -1237,9 +1237,10 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
     });
   };
 
-  function logGA(page) {
-    if (typeof trackOnGA == 'function') {
-      trackOnGA('search/' + page);
-    }
-  }
 };
+
+function logGA(page) {
+  if (typeof trackOnGA == 'function') {
+    trackOnGA('search/' + page);
+  }
+}

+ 18 - 7
desktop/core/static/js/ko.charts.js

@@ -615,13 +615,6 @@ ko.bindingHandlers.partitionChart = {
         .attr("transform", function (d) {
           return "translate(" + _x(d.y) + "," + _y(d.x) + ")";
         })
-        .on("click", click)
-        .on("dblclick", function (d, i) {
-          if (typeof _options.onClick != "undefined") {
-            chartsUpdatingState();
-            _options.onClick(d);
-          }
-        })
         .on("mouseover", function (d, i) {
           if (element.querySelectorAll("rect")[i].getBBox().height < MIN_HEIGHT_FOR_TOOLTIP) {
             _tip.attr("class", "d3-tip").show(d);
@@ -638,6 +631,24 @@ ko.bindingHandlers.partitionChart = {
           d3.select(this).select("rect").classed("mouseover", false)
         });
 
+    if (typeof _options.zoomable == "undefined" || _options.zoomable) {
+      g.on("click", click)
+       .on("dblclick", function (d, i) {
+          if (typeof _options.onClick != "undefined") {
+            chartsUpdatingState();
+            _options.onClick(d);
+          }
+        });
+    }
+    else {
+      g.on("click", function (d, i) {
+        if (typeof _options.onClick != "undefined") {
+          chartsUpdatingState();
+          _options.onClick(d);
+        }
+      });
+    }
+
     var _kx = _w / _data.dx,
         _ky = _h / 1;