Procházet zdrojové kódy

HUE-5407 [search] Bar charting of grid result can get doubled up

Enrico Berti před 9 roky
rodič
revize
3ff72e6

+ 9 - 1
apps/search/src/search/templates/common_search.mako

@@ -1094,17 +1094,25 @@ ${ dashboard.layout_skeleton() }
       <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length > 0 && $root.collection.template.showChart()">
         <div data-bind="visible: !$root.collection.template.hasDataForChart()" style="padding: 10px">${ _('Please select the chart parameters on the left.') }</div>
         <div class="grid-chart-container" data-bind="visible: $root.collection.template.hasDataForChart" style="overflow-x: auto">
+          <!-- ko if: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART -->
           <div data-bind="attr:{'id': 'pieChart_'+id()}, pieChart: {data: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data}, fqs: ko.observableArray([]),
                 transformer: pieChartDataTransformerGrid, maxWidth: 350, parentSelector: '.chart-container' }, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="chart"></div>
+          <!-- /ko -->
 
+          <!-- ko if: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART -->
           <div data-bind="attr:{'id': 'barChart_'+id()}, barChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data}, fqs: ko.observableArray([]), hideSelection: true,
-                transformer: multiSerieDataTransformerGrid, stacked: false, showLegend: true},  stacked: true, showLegend: true, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART" class="chart"></div>
+                transformer: multiSerieDataTransformerGrid, stacked: false, showLegend: true, isPivot: false},  stacked: true, showLegend: true, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART" class="chart"></div>
+          <!-- /ko -->
 
+          <!-- ko if: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART -->
           <div data-bind="attr:{'id': 'lineChart_'+id()}, lineChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data},
                 transformer: multiSerieDataTransformerGrid, showControls: false }, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART" class="chart"></div>
+          <!-- /ko -->
 
+          <!-- ko if: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP -->
           <div data-bind="attr:{'id': 'leafletMapChart_'+id()}, leafletMapChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data},
                 transformer: leafletMapChartDataTransformerGrid, showControls: false, height: 380, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP, forceRedraw: true}" class="chart"></div>
+          <!-- /ko -->
           <div class="clearfix"></div>
 
         </div>

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

@@ -1086,12 +1086,12 @@
     var _hideSelection = options.hideSelection != null ? options.hideSelection : false;
 
     if ($(element).find("svg").length > 0 && (_datum.length == 0 || _datum[0].values.length == 0)) {
-      $(element).find("svg").empty();
+      $(element).find("svg").remove();
     }
 
     if (_datum.length > 0 && _datum[0].values.length > 0 && isNaN(_datum[0].values[0].y)) {
       _datum = [];
-      $(element).find("svg").empty();
+      $(element).find("svg").remove();
     }
 
     if ($(element).is(":visible")) {
@@ -1143,7 +1143,7 @@
           }
           if (_isDiscrete && !_isPivot) {
             if ($(element).find("svg").length > 0 && $(element).find(".nv-multiBarWithLegend").length > 0) {
-              $(element).find("svg").empty();
+              $(element).find("svg").remove();
             }
             $(element).data('chart_type', 'discrete_bar');
             $(element).data('chart_pivot', false);
@@ -1161,7 +1161,7 @@
           }
           else if (_isDiscrete && _isPivot) {
             if ($(element).find("svg").length > 0 && $(element).find(".nv-discreteBarWithAxes").length > 0) {
-              $(element).find("svg").empty();
+              $(element).find("svg").remove();
             }
             $(element).data('chart_type', 'discrete_bar');
             $(element).data('chart_pivot', true);
@@ -1178,7 +1178,7 @@
           }
           else {
             if ($(element).find("svg").length > 0 && $(element).find(".nv-discreteBarWithAxes").length > 0) {
-              $(element).find("svg").empty();
+              $(element).find("svg").remove();
             }
             $(element).data('chart_type', 'multibar_brush');
             _chart = nv.models.multiBarWithBrushChart();
@@ -1764,4 +1764,4 @@
     d3.tip = tipBuilder;
   }
 
-})();
+})();