Browse Source

HUE-8402 [dashboard] Timeline: Fix numbers and filtered legend items

jdesjean 7 years ago
parent
commit
2c115eaa4b

+ 7 - 4
desktop/core/src/desktop/static/desktop/js/nv.d3.lineWithBrushChart.js

@@ -228,6 +228,9 @@ nv.models.lineWithBrushChart = function() {
         legend.height(availableHeight);
         legend.rightAlign(false);
         legend.margin({top: 5, right: 0, left: 10, bottom: 0});
+        data.forEach(function(series,i) {
+          series.color = color(series, i);
+        });
 
         try {
           legendG
@@ -697,7 +700,7 @@ nv.models.lineWithBrushChart = function() {
               lines.dispatch.elementMouseover({
                 value: getY(d),
                 point: d,
-                series: data[d.series],
+                series: filteredData[d.series],
                 pos: [x(getX(d)), y(getY(d))],
                 pointIndex: -1,
                 seriesIndex: d.series,
@@ -705,7 +708,7 @@ nv.models.lineWithBrushChart = function() {
                   return {
                     value: getY(d),
                     point: d,
-                    series: data[d.series],
+                    series: filteredData[d.series],
                     pos: [x(getX(d)), y(getY(d))],
                     pointIndex: -1,
                     seriesIndex: d.series,
@@ -725,7 +728,7 @@ nv.models.lineWithBrushChart = function() {
             lines.dispatch.elementMouseout({
               value: getY(d),
               point: d,
-              series: data[d.series],
+              series: filteredData[d.series],
               pointIndex: d.index,
               seriesIndex: d.series,
               e: d3v3.event
@@ -739,7 +742,7 @@ nv.models.lineWithBrushChart = function() {
         lines.dispatch.elementClick({
           value: getY(d),
           point: d,
-          series: data[d.series],
+          series: filteredData[d.series],
           pointIndex: d.index,
           seriesIndex: d.series,
           e: d3v3.event

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

@@ -249,10 +249,15 @@ nv.models.multiBarWithBrushChart = function() {
         legend.height(availableHeight);
         legend.rightAlign(false);
         legend.margin({top: 5, right: 0, left: 10, bottom: 0});
-        if (multibar.barColor())
+        if (multibar.barColor()) {
           data.forEach(function(series,i) {
             series.color = d3v3.rgb('#ccc').darker(i * 1.5).toString();
           });
+        } else {
+          data.forEach(function(series,i) {
+            series.color = color(series, i);
+          });
+        }
 
         try {
           legendG
@@ -755,7 +760,7 @@ nv.models.multiBarWithBrushChart = function() {
             multibar.dispatch.elementMouseout({
               value: getY(d,i),
               point: d,
-              series: data[d.series],
+              series: filteredData[d.series],
               pointIndex: i,
               seriesIndex: d.series,
               e: d3v3.event
@@ -787,7 +792,7 @@ nv.models.multiBarWithBrushChart = function() {
                   return {
                     value: getY(d),
                     point: d,
-                    series: data[d.series],
+                    series: filteredData[d.series],
                     pos: [x(getX(d)) + width * 0.5, y(getY(d) + (multibar.stacked() ? d.y0 : 0))],
                     pointIndex: -1,
                     seriesIndex: d.series,
@@ -807,7 +812,7 @@ nv.models.multiBarWithBrushChart = function() {
             multibar.dispatch.elementMouseout({
               value: getY(d,i),
               point: d,
-              series: data[d.series],
+              series: filteredData[d.series],
               pointIndex: d.index,
               seriesIndex: d.series,
               e: d3v3.event
@@ -821,7 +826,7 @@ nv.models.multiBarWithBrushChart = function() {
         multibar.dispatch.elementClick({
           value: getY(d),
           point: d,
-          series: data[d.series],
+          series: filteredData[d.series],
           pointIndex: d.index,
           seriesIndex: d.series,
           e: d3v3.event

+ 2 - 1
desktop/libs/dashboard/src/dashboard/facet_builder.py

@@ -56,7 +56,8 @@ TIME_INTERVALS_STARTING_VALUE = {
   'minute': 0,
   'hour': 0,
   'day': 1,
-  'month': 1
+  'month': 1,
+  'year': 0
 }
 TIME_INTERVAL_SORTED = ['microsecond', 'second', 'minute', 'hour', 'day', 'month']
 TIME_INTERVALS = [

+ 8 - 4
desktop/libs/libsolr/src/libsolr/api.py

@@ -952,13 +952,16 @@ class SolrApi(object):
       _compute_range_facet(facet['widgetType'], stat_facet, props, properties['start'], properties['end'],
                            SLOTS=properties['slot'])
       gap = props['gap']
-      unit = re.split('\d+', gap)[1]
+      if isinstance(gap, basestring):
+        unit = re.split('\d+', gap)[1]
+      else:
+        unit = ''
       return {
         'min': '%(min)s' % props,
         'max': '%(max)s' % props,
         'start': '%(start)s' % props,
         'end': '%(end)s' % props,
-        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit},
+        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit} if unit else '%(gap)s' % {'gap': gap},
       }
     elif timeFilter:
       props = {}
@@ -973,11 +976,12 @@ class SolrApi(object):
         stat_facet = {'min': properties['min'], 'max': properties['max']}
       _compute_range_facet(facet['widgetType'], stat_facet, props, properties['start'], properties['end'], SLOTS = properties['slot'])
       gap = props['gap']
-      unit = re.split('\d+', gap)[1]
+      if isinstance(gap, basestring):
+        unit = re.split('\d+', gap)[1]
       return {
         'start': '%(start)s' % props,
         'end': '%(end)s' % props,
-        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit},
+        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit} if unit else '%(gap)s' % {'gap': gap},
         'min': '%(min)s' % props,
         'max': '%(max)s' % props,
       }