You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/06/23 05:05:12 UTC
(superset) branch fix/issue-21734-forecast-tooltip-zero created (now 40339257bdb)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a change to branch fix/issue-21734-forecast-tooltip-zero
in repository https://gitbox.apache.org/repos/asf/superset.git
at 40339257bdb fix(plugin-chart-echarts): show forecast tooltip values when they equal zero
This branch includes the following new commits:
new 40339257bdb fix(plugin-chart-echarts): show forecast tooltip values when they equal zero
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(plugin-chart-echarts): show forecast tooltip values when they equal zero
Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch fix/issue-21734-forecast-tooltip-zero
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 40339257bdbc6f9696f22fdbd8f2728c08750fb6
Author: Evan <ev...@preset.io>
AuthorDate: Mon Jun 22 22:04:46 2026 -0700
fix(plugin-chart-echarts): show forecast tooltip values when they equal zero
The forecast tooltip formatter used truthiness checks on the forecast trend
and confidence-bound values, so a legitimate value of exactly 0 was silently
dropped from the tooltip. This is what users saw as the confidence band
"disappearing" when a forecast crossed zero (issue #21734): a forecast trend
of 0, a lower bound of 0, or a zero-height band would render no interval at
all.
Switch the conditionals to explicit `typeof === 'number'` checks (matching the
existing pattern used for the observation value) so zero values are formatted
and shown like any other number.
Fixes #21734
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
.../plugin-chart-echarts/src/utils/forecast.ts | 12 +++--
.../test/utils/forecast.test.ts | 55 ++++++++++++++++++++++
2 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts
index 47cf7d63440..3a588e70091 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts
@@ -98,15 +98,21 @@ export const formatForecastTooltipSeries = ({
}): string[] => {
const name = `${marker}${sanitizeHtml(seriesName)}`;
let value = typeof observation === 'number' ? formatter(observation) : '';
- if (forecastTrend || forecastLower || forecastUpper) {
+ // Use explicit numeric checks rather than truthiness so that legitimate
+ // zero values (e.g. a forecast that crosses zero, or a confidence bound of
+ // exactly 0) are not dropped from the tooltip.
+ const hasTrend = typeof forecastTrend === 'number';
+ const hasLower = typeof forecastLower === 'number';
+ const hasUpper = typeof forecastUpper === 'number';
+ if (hasTrend || hasLower || hasUpper) {
// forecast values take the form of "20, y = 30 (10, 40)"
// where the first part is the observation, the second part is the forecast trend
// and the third part is the lower and upper bounds
- if (forecastTrend) {
+ if (hasTrend) {
if (value) value += ', ';
value += `ŷ = ${formatter(forecastTrend)}`;
}
- if (forecastLower && forecastUpper) {
+ if (hasLower && hasUpper) {
if (value) value += ' ';
// the lower bound needs to be added to the upper bound
value += `(${formatter(forecastLower)}, ${formatter(
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts
index a347ff918fd..1d7c8d2f98a 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts
@@ -342,3 +342,58 @@ test('formatForecastTooltipSeries should format forecast with only confidence ba
}),
).toEqual(['<img>qwerty', '(7, 15)']);
});
+
+test('formatForecastTooltipSeries should show forecast trend equal to zero', () => {
+ expect(
+ formatForecastTooltipSeries({
+ seriesName: 'qwerty',
+ marker: '<img>',
+ observation: 10,
+ forecastTrend: 0,
+ forecastLower: 5,
+ forecastUpper: 7,
+ formatter,
+ }),
+ ).toEqual(['<img>qwerty', '10, ŷ = 0 (5, 12)']);
+});
+
+test('formatForecastTooltipSeries should show confidence band when lower bound is zero', () => {
+ expect(
+ formatForecastTooltipSeries({
+ seriesName: 'qwerty',
+ marker: '<img>',
+ observation: 10,
+ forecastTrend: 5,
+ forecastLower: 0,
+ forecastUpper: 7,
+ formatter,
+ }),
+ ).toEqual(['<img>qwerty', '10, ŷ = 5 (0, 7)']);
+});
+
+test('formatForecastTooltipSeries should show confidence band when band height is zero', () => {
+ expect(
+ formatForecastTooltipSeries({
+ seriesName: 'qwerty',
+ marker: '<img>',
+ observation: 10,
+ forecastTrend: 5,
+ forecastLower: 4,
+ forecastUpper: 0,
+ formatter,
+ }),
+ ).toEqual(['<img>qwerty', '10, ŷ = 5 (4, 4)']);
+});
+
+test('formatForecastTooltipSeries should show forecast trend and band all at zero', () => {
+ expect(
+ formatForecastTooltipSeries({
+ seriesName: 'qwerty',
+ marker: '<img>',
+ forecastTrend: 0,
+ forecastLower: 0,
+ forecastUpper: 0,
+ formatter,
+ }),
+ ).toEqual(['<img>qwerty', 'ŷ = 0 (0, 0)']);
+});