From 52a0847e8ff4a653ab34194c54af5a24870a6193 Mon Sep 17 00:00:00 2001 From: Trdat Mkrtchyan Date: Wed, 8 Nov 2023 17:22:34 +0400 Subject: [PATCH] fix: fixed tooltip render on pin with empty data (#176) --- src/YagrCore/plugins/tooltip/tooltip.ts | 9 +++++++++ src/YagrCore/utils/series.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/src/YagrCore/plugins/tooltip/tooltip.ts b/src/YagrCore/plugins/tooltip/tooltip.ts index 7b77b35..dfb8d3c 100644 --- a/src/YagrCore/plugins/tooltip/tooltip.ts +++ b/src/YagrCore/plugins/tooltip/tooltip.ts @@ -465,6 +465,15 @@ class YagrTooltip { x, }; + const hasDataNow = Object.values(sections).some( + ({rows}) => rows.filter(({id}) => this.yagr.getSeriesById(id)?.show).length > 0, + ); + + if (!hasDataNow) { + this.hide(); + return; + } + if (!opts.virtual) { this.tOverlay.innerHTML = opts.render({ ...renderData, diff --git a/src/YagrCore/utils/series.ts b/src/YagrCore/utils/series.ts index 2772e57..7d7e3c3 100644 --- a/src/YagrCore/utils/series.ts +++ b/src/YagrCore/utils/series.ts @@ -132,6 +132,7 @@ export function configureSeries(yagr: Yagr, rawSeries: RawSerieData, idx: number export const overrideSeriesInUpdate = (dest: Series, source: Series) => { dest.$c = source.$c ?? dest.$c; + dest.show = source.show ?? dest.show; dest.data = source.data ?? dest.data; dest.width = source.width ?? dest.width; dest.pointsSize = source.pointsSize ?? dest.pointsSize;