superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: [fix] hide annotation layer (#6204)
Date Sat, 27 Oct 2018 00:12:36 GMT
This is an automated email from the ASF dual-hosted git repository.

graceguo 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 87161a6  [fix] hide annotation layer (#6204)
87161a6 is described below

commit 87161a6d5d19a3ebc206df4e941ad2a2c95cc77b
Author: Grace Guo <grace.guo@airbnb.com>
AuthorDate: Fri Oct 26 17:12:30 2018 -0700

    [fix] hide annotation layer (#6204)
---
 superset/assets/src/visualizations/nvd3/NVD3Vis.js | 28 ++++++++++++----------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/superset/assets/src/visualizations/nvd3/NVD3Vis.js b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
index 90a90d3..a67c93f 100644
--- a/superset/assets/src/visualizations/nvd3/NVD3Vis.js
+++ b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
@@ -226,6 +226,7 @@ function nvd3Vis(element, props) {
   const isExplore = document.querySelector('#explorer-container') !== null;
   const container = element;
   container.innerHTML = '';
+  const activeAnnotationLayers = annotationLayers.filter(layer => layer.show);
 
   let chart;
   let width = maxWidth;
@@ -642,10 +643,9 @@ function nvd3Vis(element, props) {
         chart.yAxis.axisLabel(yAxisLabel).axisLabelDistance(distance);
       }
 
-      if (isTimeSeries && annotationData && annotationLayers.length >
0) {
+      if (isTimeSeries && annotationData && activeAnnotationLayers.length
> 0) {
         // Time series annotations add additional data
-        const timeSeriesAnnotations = annotationLayers
-          .filter(layer => layer.show)
+        const timeSeriesAnnotations = activeAnnotationLayers
           .filter(layer => layer.annotationType === ANNOTATION_TYPES.TIME_SERIES)
           .reduce((bushel, a) =>
             bushel.concat((annotationData[a.name] || []).map((series) => {
@@ -677,9 +677,9 @@ function nvd3Vis(element, props) {
       window.addEventListener('scroll', throttle(hideTooltips, 250));
 
       // The below code should be run AFTER rendering because chart is updated in call()
-      if (isTimeSeries && annotationLayers.length > 0) {
+      if (isTimeSeries && activeAnnotationLayers.length > 0) {
         // Formula annotations
-        const formulas = annotationLayers
+        const formulas = activeAnnotationLayers
           .filter(a => a.annotationType === ANNOTATION_TYPES.FORMULA)
           .map(a => ({ ...a, formula: mathjs.parse(a.value) }));
 
@@ -749,10 +749,11 @@ function nvd3Vis(element, props) {
 
         if (annotationData) {
           // Event annotations
-          annotationLayers.filter(x => (
-            x.annotationType === ANNOTATION_TYPES.EVENT &&
-            annotationData && annotationData[x.name]
-          )).forEach((config, index) => {
+          activeAnnotationLayers
+            .filter(x => (
+              x.annotationType === ANNOTATION_TYPES.EVENT &&
+              annotationData && annotationData[x.name]
+            )).forEach((config, index) => {
             const e = applyNativeColumns(config);
             // Add event annotation layer
             const annotations = d3.select(element)
@@ -808,10 +809,11 @@ function nvd3Vis(element, props) {
           });
 
           // Interval annotations
-          annotationLayers.filter(x => (
-            x.annotationType === ANNOTATION_TYPES.INTERVAL &&
-            annotationData && annotationData[x.name]
-          )).forEach((config, index) => {
+          activeAnnotationLayers
+            .filter(x => (
+              x.annotationType === ANNOTATION_TYPES.INTERVAL &&
+              annotationData && annotationData[x.name]
+            )).forEach((config, index) => {
             const e = applyNativeColumns(config);
             // Add interval annotation layer
             const annotations = d3.select(element)


Mime
View raw message