瀏覽代碼

[search] Allow null state or country on the map chart

Grouped also lower/uppercase state values
Fixed indexing of the color scale
Enrico Berti 10 年之前
父節點
當前提交
9dfc45e8fc
共有 2 個文件被更改,包括 19 次插入6 次删除
  1. 18 5
      apps/search/src/search/templates/search.mako
  2. 1 1
      desktop/core/src/desktop/static/desktop/js/ko.charts.js

+ 18 - 5
apps/search/src/search/templates/search.mako

@@ -2196,11 +2196,24 @@ function mapChartDataTransformer(data) {
     item.values = item.pivot ? item.pivot[0].fq_values : item.fq_values;
     item.counts = item.pivot ? item.pivot[0].count : item.count; // unused yet
     item.is2d = item.pivot ? true : false; // unused yet
-    _data.push({
-      label: data.scope == "world" ? HueGeo.getISOAlpha3(item.value) : item.value,
-      value: item.pivot ? item.pivot[0].fq_values : item.count,
-      obj: item
-    });
+    if (item.value != null && item.value != "" && item.value.length < 4) {
+      var _label = data.scope == "world" ? HueGeo.getISOAlpha3(item.value) : item.value.toUpperCase();
+      var _found = false;
+      for (var i = 0; i < _data.length; i++) { // we group lower and upper cases together
+        if (_data[i].label == _label) {
+          _data[i].value += item.pivot ? item.pivot[0].fq_values : item.count;
+          _found = true;
+          break;
+        }
+      }
+      if (!_found) {
+        _data.push({
+          label: _label,
+          value: item.pivot ? item.pivot[0].fq_values : item.count,
+          obj: item
+        });
+      }
+    }
   });
   return _data;
 }

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/ko.charts.js

@@ -541,7 +541,7 @@ ko.bindingHandlers.mapChart = {
         var _place = typeof item.label == "String" ? item.label.toUpperCase() : item.label;
         if (_place != null) {
           _mapdata[_place] = {
-            fillKey: "fill_" + (_is2d ? getHighestCategoryValue(cnt, item).idx : (Math.floor(item.value / _chunk) - 1)),
+            fillKey: "fill_" + (_is2d ? getHighestCategoryValue(cnt, item).idx : (Math.ceil(item.value / _chunk) - 1)),
             id: _place,
             cat: item.obj.cat,
             value: item.obj.values ? item.obj.values : item.obj.value,