Эх сурвалжийг харах

HUE-5116 [search] Support of dimension 1 of Gradient Map

Romain Rigaux 9 жил өмнө
parent
commit
2a883cf051

+ 2 - 1
apps/search/src/search/static/search/js/search.ko.js

@@ -667,7 +667,8 @@ var Collection = function (vm, collection) {
       facet.template.chartSettings.chartType.subscribe(function(newValue) {
         facet.widgetType(
             newValue == ko.HUE_CHARTS.TYPES.PIECHART ? 'pie2-widget' :
-            (newValue == ko.HUE_CHARTS.TYPES.TIMELINECHART ? 'timeline-widget' : 'bucket-widget')
+            (newValue == ko.HUE_CHARTS.TYPES.TIMELINECHART ? 'timeline-widget' :
+            (newValue == ko.HUE_CHARTS.TYPES.GRADIENTMAP ? 'gradient-map-widget' : 'bucket-widget'))
         );
       });
     }

+ 40 - 30
apps/search/src/search/templates/common_search.mako

@@ -1391,6 +1391,7 @@ ${ dashboard.layout_skeleton() }
             <i class="hcha hcha-line-chart fa-fw" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART" style="display: none;"></i>
             <i class="hcha hcha-pie-chart fa-fw" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART" style="display: none;"></i>
             <i class="fa fa-fw fa-line-chart" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART" style="display: none;"></i>
+            <i class="hcha hcha-map-chart fa-fw" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" style="display: none;"></i>
             <i class="fa fa-fw fa-map-marker" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP" style="display: none;"></i>
           </a>
           <a class="dropdown-toggle grid-side-btn" style="padding:0" data-toggle="dropdown"
@@ -1418,14 +1419,19 @@ ${ dashboard.layout_skeleton() }
                 <i class="hcha hcha-pie-chart fa-fw"></i> ${_('Pie')}
               </a>
             </li>
-            <!-- ko if: widgetType() != 'resultset-widget' -->
+            ##<!-- ko if: widgetType() != 'resultset-widget' -->
             <li>
               <a href="javascript:void(0)"
                  data-bind="css: {'active': template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART}, click: function(){ template.showChart(true); template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.TIMELINECHART); template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}">
-                <i class="fa fa-fw fa-line-chart"></i> ${_('timeline')}
+                <i class="fa fa-fw fa-line-chart"></i> ${_('Timeline')}
+              </a>
+            </li>
+            <li>
+              <a href="javascript:void(0)"
+                 data-bind="css: {'active': template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP}, click: function(){ template.showChart(true); template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.GRADIENTMAP); template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}">
+                <i class="hcha fa-fw hcha-map-chart chart-icon"></i> ${_('Gradient Map')}
               </a>
             </li>
-            <!-- /ko -->
             <li>
               <a href="javascript:void(0)"
                  data-bind="css: {'active': template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP}, click: function(){ template.showChart(true); template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.MAP); template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}">
@@ -1618,19 +1624,31 @@ ${ dashboard.layout_skeleton() }
            <!-- /ko -->
          <!-- /ko -->               
 
+        <!-- ko if: widgetType() == 'gradient-map-widget' -->
+          <!-- ko with: $parent -->
+            <div data-bind="mapChart: {data: {counts: counts(), scope: $parent.properties.scope()},
+              transformer: mapChartDataTransformer,
+              maxWidth: 750,
+              isScale: true,
+              onClick: function(d) {
+                $root.query.togglePivotFacet({facet: {'fq_fields': d.cat, 'fq_values': d.value}, widget_id: id()});
+              },
+              onComplete: function(){ var widget = viewModel.getWidgetById($parent.id()); if (widget != null) { widget.isLoading(false)}; } }" />
+           <!-- /ko -->
+         <!-- /ko --> 
 
-    <!-- ko if: widgetType() == 'timeline-widget' -->
-      <!-- ko with: $parent -->
-      <div data-bind="timelineChart: {datum: {counts: counts(), extraSeries: extraSeries(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(), field: field, label: label(), transformer: timelineChartDataTransformer,
-        type: $root.collection.getFacetById($parent.id()).properties.timelineChartType,
-        fqs: $root.query.fqs,
-        onSelectRange: function(from, to){ $root.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
-        onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
-        onClick: function(d){ $root.query.selectRangeFacet({count: d.obj.value, widget_id: $parent.id(), from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
-        onComplete: function(){ $root.getWidgetById($parent.id()).isLoading(false) }}" />
-      <div class="clearfix"></div>
-      <!-- /ko -->
-    <!-- /ko -->
+        <!-- ko if: widgetType() == 'timeline-widget' -->
+          <!-- ko with: $parent -->
+          <div data-bind="timelineChart: {datum: {counts: counts(), extraSeries: extraSeries(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(), field: field, label: label(), transformer: timelineChartDataTransformer,
+            type: $root.collection.getFacetById($parent.id()).properties.timelineChartType,
+            fqs: $root.query.fqs,
+            onSelectRange: function(from, to){ $root.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
+            onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
+            onClick: function(d){ $root.query.selectRangeFacet({count: d.obj.value, widget_id: $parent.id(), from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
+            onComplete: function(){ $root.getWidgetById($parent.id()).isLoading(false) }}" />
+          <div class="clearfix"></div>
+          <!-- /ko -->
+        <!-- /ko -->
 
 
     <!-- ko if: widgetType() == 'pie2-widget' -->
@@ -2261,30 +2279,22 @@ ${ dashboard.layout_skeleton() }
     <div data-bind="with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
       <span data-bind="template: { name: 'facet-toggle2' }"></span>
     </div>
-
+    
+    <!-- ko with: $root.collection.getFacetById($parent.id()) -->
     <div class="margin-bottom-10" data-bind="visible: ! $root.isEditing()">
-      <div data-bind="with: $root.collection.getFacetById($parent.id())">
+
         <!-- ko if: $data.properties.facets().length == 1 -->
           <div class="margin-bottom-10">
             <span data-bind="text: $data.properties.facets()[0].field"></span>
           </div>
         <!-- /ko -->
-      </div>
     </div>
 
-    <div data-bind="with: $root.collection.getFacetById($parent.id())">
-      <div data-bind="mapChart: {data: {counts: $parent.counts(), scope: $root.collection.getFacetById($parent.id()).properties.scope()},
-        transformer: mapChartDataTransformer,
-        maxWidth: 750,
-        isScale: true,
-        onClick: function(d) {
-          $root.query.togglePivotFacet({facet: {'fq_fields': d.fields, 'fq_values': d.value}, widget_id: id()});
-        },
-        onComplete: function(){ var widget = viewModel.getWidgetById($parent.id()); if (widget != null) { widget.isLoading(false)}; } }" />
-      <div class="clearfix"></div>
-    </div>
-  </div>
+      <span data-bind="template: { name: 'data-grid' }"></span>
+    <!-- /ko -->
+  </div>  
   <!-- /ko -->
+
   <div class="widget-spinner" data-bind="visible: isLoading()">
     <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
     <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->

+ 2 - 2
apps/search/src/search/views.py

@@ -580,7 +580,7 @@ def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_t
     facet_type = 'nested'
     properties['facets'] = []
     properties['domain'] = {'blockParent': [], 'blockChildren': []}
-    properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 10, 'aggregate': 'count'}
+    properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 10, 'aggregate': {'function': 'unique', 'ops': [], 'percentiles': [{'value': 50}]}}
     properties['scope'] = 'world'
     properties['limit'] = 100
   else:
@@ -643,7 +643,7 @@ def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_t
         "showGrid": False,
         "showChart": True,
         "chartSettings" : {
-          'chartType': 'pie' if widget_type == 'pie2-widget' else ('timeline' if widget_type == 'timeline-widget' else 'bars'),
+          'chartType': 'pie' if widget_type == 'pie2-widget' else ('timeline' if widget_type == 'timeline-widget' else ('gradientmap' if widget_type == 'gradient-map-widget' else 'bars')),
           'chartSorting': 'none',
           'chartScatterGroup': None,
           'chartScatterSize': None,