You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2018/11/28 04:54:33 UTC

[incubator-superset] branch master updated: fix Calendar Heatmap (#6445)

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 <ab...@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'),