Преглед на файлове

HUE-5083 [charts] Improve redistribution of labels on bar charts

Enrico Berti преди 9 години
родител
ревизия
b5b46b9aa2
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      desktop/core/src/desktop/static/desktop/js/nv.d3.growingDiscreteBarChart.js

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

@@ -212,10 +212,14 @@ nv.models.growingDiscreteBarChart = function() {
                   var self = d3.select(this),
                     textLength = self.node().getComputedTextLength(),
                     text = self.text();
-                  while (textLength > rangeBand && text.length > 0) {
+                  while (textLength > rangeBand*2 && text.length > 0) {
                     text = text.slice(0, -1);
                     self.text(text + '...');
                     textLength = self.node().getComputedTextLength();
+                    if (self.text() == '...') {
+                      self.text(' ');
+                      textLength = 0;
+                    }
                   }
                   return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')'
                 });