Browse Source

HUE-2679 [search] Improved switching between data and no available data

Enrico Berti 10 years ago
parent
commit
a87f374ef9

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

@@ -329,9 +329,11 @@ ko.bindingHandlers.leafletMapChart = {
     }
     if (((_options.visible != null && _options.visible) || _options.visible == null || typeof _options == "undefined") && _data.length > 0) {
       $(element).show();
+      $(element).siblings(".leaflet-nodata").remove();
     }
     else {
       $(element).hide();
+      $(element).before($("<div>").addClass("leaflet-nodata").css("textAlign", "center").text("No Data Available."));
     }
 
     var _map = null;

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

@@ -111,9 +111,13 @@ nv.models.growingDiscreteBarChart = function() {
           .attr('y', margin.top + availableHeight / 2)
           .text(function(d) { return d });
 
+        container.selectAll('.nv-discreteBarWithAxes').style('visibility', 'hidden');
+        container.selectAll('.nv-noData').style('visibility', 'visible');
+
         return chart;
       } else {
-        container.selectAll('.nv-noData').remove();
+        container.selectAll('.nv-discreteBarWithAxes').style('visibility', 'visible');
+        container.selectAll('.nv-noData').style('visibility', 'hidden');
       }
 
       //------------------------------------------------------------

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

@@ -135,9 +135,13 @@ nv.models.growingMultiBarChart = function() {
           .attr('y', margin.top + availableHeight / 2)
           .text(function(d) { return d });
 
+        container.selectAll('.nv-multiBarWithLegend').style('visibility', 'hidden');
+        container.selectAll('.nv-noData').style('visibility', 'visible');
+
         return chart;
       } else {
-        container.selectAll('.nv-noData').remove();
+        container.selectAll('.nv-multiBarWithLegend').style('visibility', 'visible');
+        container.selectAll('.nv-noData').style('visibility', 'hidden');
       }
 
       //------------------------------------------------------------

+ 15 - 2
desktop/core/src/desktop/static/desktop/js/nv.d3.growingPieChart.js

@@ -92,7 +92,16 @@ nv.models.growingPieChart = function() {
       //------------------------------------------------------------
       // Display No Data message if there's nothing to show.
 
-      if (!data || !data.length) {
+      var _allDataIsZero = true;
+      if (data){
+        data.forEach(function(obj){
+          if (obj.value > 0){
+            _allDataIsZero = false;
+          }
+        });
+      }
+
+      if (!data || !data.length || _allDataIsZero) {
         var noDataText = container.selectAll('.nv-noData').data([noData]);
 
         noDataText.enter().append('text')
@@ -105,9 +114,13 @@ nv.models.growingPieChart = function() {
           .attr('y', margin.top + availableHeight / 2)
           .text(function(d) { return d });
 
+        container.selectAll('.nv-pieChart').style('visibility', 'hidden');
+        container.selectAll('.nv-noData').style('visibility', 'visible');
+
         return chart;
       } else {
-        container.selectAll('.nv-noData').remove();
+        container.selectAll('.nv-pieChart').style('visibility', 'visible');
+        container.selectAll('.nv-noData').style('visibility', 'hidden');
       }
 
       //------------------------------------------------------------

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

@@ -160,9 +160,13 @@ nv.models.multiBarWithBrushChart = function() {
           .attr('y', margin.top + availableHeight / 2)
           .text(function(d) { return d });
 
+        container.selectAll('.nv-multiBarWithLegend').style('visibility', 'hidden');
+        container.selectAll('.nv-noData').style('visibility', 'visible');
+
         return chart;
       } else {
-        container.selectAll('.nv-noData').remove();
+        container.selectAll('.nv-multiBarWithLegend').style('visibility', 'visible');
+        container.selectAll('.nv-noData').style('visibility', 'hidden');
       }
 
       //------------------------------------------------------------