Преглед изворни кода

HUE-7261 [editor] Prevent enormous chart legend labels to take over the chart

Enrico Berti пре 8 година
родитељ
комит
8cdb597b6d

+ 10 - 4
desktop/core/src/desktop/static/desktop/js/nv.d3.growingMultiBarChart.js

@@ -187,10 +187,16 @@ nv.models.growingMultiBarChart = function() {
             .datum(data)
             .call(legend);
 
-        if ( margin.top != legend.height()) {
-          margin.top = legend.height();
-          availableHeight = (height || parseInt(container.style('height')) || 400)
-                             - margin.top - margin.bottom;
+        if (legend.height() > 50) {
+          g.select('.nv-legendWrap').style('visibility', 'hidden');
+        }
+        else {
+          g.select('.nv-legendWrap').style('visibility', 'visible');
+          if (margin.top != legend.height()) {
+            margin.top = legend.height();
+            availableHeight = (height || parseInt(container.style('height')) || 400)
+              - margin.top - margin.bottom;
+          }
         }
 
         g.select('.nv-legendWrap')

+ 10 - 4
desktop/core/src/desktop/static/desktop/js/nv.d3.growingPieChart.js

@@ -151,10 +151,16 @@ nv.models.growingPieChart = function() {
             .datum(data)
             .call(legend);
 
-        if ( margin.top != legend.height()) {
-          margin.top = legend.height();
-          availableHeight = (height || parseInt(container.style('height')) || 400)
-                             - margin.top - margin.bottom;
+        if (legend.height() > 50) {
+          wrap.select('.nv-legendWrap').style('visibility', 'hidden');
+        }
+        else {
+          wrap.select('.nv-legendWrap').style('visibility', 'visible');
+          if (margin.top != legend.height()) {
+            margin.top = legend.height();
+            availableHeight = (height || parseInt(container.style('height')) || 400)
+              - margin.top - margin.bottom;
+          }
         }
 
         wrap.select('.nv-legendWrap')