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: Make brush send events (#5663)
Date Wed, 22 Aug 2018 04:40:29 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 2a8cd43  Make brush send events (#5663)
2a8cd43 is described below

commit 2a8cd438819a01707929d95dc2c23321c1422d4d
Author: Beto Dealmeida <roberto@dealmeida.net>
AuthorDate: Tue Aug 21 21:40:26 2018 -0700

    Make brush send events (#5663)
    
    * Make brush send events
    
    * Make sure object is date
    
    * Send event only on brushend
---
 superset/assets/src/explore/controls.jsx       |  8 ++++++++
 superset/assets/src/explore/visTypes.jsx       |  2 +-
 superset/assets/src/visualizations/nvd3_vis.js | 11 +++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/superset/assets/src/explore/controls.jsx b/superset/assets/src/explore/controls.jsx
index 0900d2c..917a274 100644
--- a/superset/assets/src/explore/controls.jsx
+++ b/superset/assets/src/explore/controls.jsx
@@ -1495,6 +1495,14 @@ export const controls = {
     description: t('Whether to display the legend (toggles)'),
   },
 
+  send_time_range: {
+    type: 'CheckboxControl',
+    label: t('Propagate'),
+    renderTrigger: true,
+    default: false,
+    description: t('Send range filter events to other charts'),
+  },
+
   show_labels: {
     type: 'CheckboxControl',
     label: t('Show Labels'),
diff --git a/superset/assets/src/explore/visTypes.jsx b/superset/assets/src/explore/visTypes.jsx
index 69b1297..ac4285c 100644
--- a/superset/assets/src/explore/visTypes.jsx
+++ b/superset/assets/src/explore/visTypes.jsx
@@ -179,7 +179,7 @@ export const visTypes = {
         expanded: true,
         controlSetRows: [
           ['color_scheme'],
-          ['show_brush', 'show_legend'],
+          ['show_brush', 'send_time_range', 'show_legend'],
           ['rich_tooltip', 'show_markers'],
           ['line_interpolation'],
         ],
diff --git a/superset/assets/src/visualizations/nvd3_vis.js b/superset/assets/src/visualizations/nvd3_vis.js
index efa8064..1baf5f5 100644
--- a/superset/assets/src/visualizations/nvd3_vis.js
+++ b/superset/assets/src/visualizations/nvd3_vis.js
@@ -363,6 +363,17 @@ export default function nvd3Vis(slice, payload) {
         throw new Error('Unrecognized visualization for nvd3' + vizType);
     }
 
+    if (isTruthy(fd.show_brush) && isTruthy(fd.send_time_range)) {
+      chart.focus.dispatch.on('brush', (event) => {
+        const extent = event.extent;
+        if (extent.some(d => d.toISOString === undefined)) {
+          return;
+        }
+        const timeRange = extent.map(d => d.toISOString().slice(0, -1)).join(' : ');
+        event.brush.on('brushend', () => slice.addFilter('__time_range', timeRange, false,
true));
+      });
+    }
+
     if (chart.xAxis && chart.xAxis.staggerLabels) {
       chart.xAxis.staggerLabels(staggerLabels);
     }


Mime
View raw message