superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: fix Calendar Heatmap (#6445)
Date Wed, 28 Nov 2018 04:54:33 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 529cb5c  fix Calendar Heatmap (#6445)
529cb5c is described below

commit 529cb5cab1903b00800afc85aa42cf25c124373c
Author: aboganas <aboganas@users.noreply.github.com>
AuthorDate: Wed Nov 28 07:54:25 2018 +0300

    fix Calendar Heatmap (#6445)
    
    * fix  D3 v4.0, selections are not arrays anymore
    
    * added vale checking
    
    * fixed linting
    
    * cleanup
---
 superset/assets/src/visualizations/Calendar/Calendar.js |  2 +-
 superset/viz.py                                         | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/superset/assets/src/visualizations/Calendar/Calendar.js b/superset/assets/src/visualizations/Calendar/Calendar.js
index 5b7bfe7..6b7aada 100644
--- a/superset/assets/src/visualizations/Calendar/Calendar.js
+++ b/superset/assets/src/visualizations/Calendar/Calendar.js
@@ -95,7 +95,7 @@ function Calendar(element, props) {
     cal.init({
       start: UTCTS(data.start),
       data: timestamps,
-      itemSelector: calContainer[0][0],
+      itemSelector: calContainer.node(),
       legendVerticalPosition: 'top',
       cellSize,
       cellPadding,
diff --git a/superset/viz.py b/superset/viz.py
index e3e891a..a3c5f06 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -789,10 +789,13 @@ class CalHeatmapViz(BaseViz):
         data = {}
         records = df.to_dict('records')
         for metric in self.metric_labels:
-            data[metric] = {
-                str(obj[DTTM_ALIAS] / 10**9): obj.get(metric)
-                for obj in records
-            }
+            values = {}
+            for obj in records:
+                v = obj[DTTM_ALIAS]
+                if hasattr(v, 'value'):
+                    v = v.value
+                values[str(v / 10**9)] = obj.get(metric)
+            data[metric] = values
 
         start, end = utils.get_since_until(form_data.get('time_range'),
                                            form_data.get('since'),


Mime
View raw message