graceguo-supercat closed pull request #6204: [fix] hide annotation layer
URL: https://github.com/apache/incubator-superset/pull/6204
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/visualizations/nvd3/NVD3Vis.js 
b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
index 90a90d3155..a67c93fb71 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)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to