[fix] hide annotation layer (#6204)
This commit is contained in:
parent
dcf048c52e
commit
87161a6d5d
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue