Skip to content

fix(chart): Restore subheader used in bignumber with trendline #33196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Apr 25, 2025

Conversation

LevisNgigi
Copy link
Contributor

@LevisNgigi LevisNgigi commented Apr 21, 2025

SUMMARY

We lost the subheader in the big number with trendline as we tried to map it to subtitle.This aims at restoring the subheader being used in big number with trendline.
related to this pr

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE
before

AFTER
after

TESTING INSTRUCTIONS

1)Create or open a chart using Big Number with Trendline chart configured with subheader/comparison suffix such as Wow,MoM etc
2)Confirm that the chart displays the subheader as expected.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@@ -294,6 +343,11 @@ class BigNumberVis extends PureComponent<BigNumberVizProps> {
{this.renderHeader(
Math.ceil(headerFontSize * (1 - PROPORTION.TRENDLINE) * height),
)}
{this.rendermetricComparisonSummary(
Math.ceil(
subheaderFontSize * (1 - PROPORTION.TRENDLINE) * height,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename this to metricComparisonFontSize?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can,this means the subheader font size in the UI needs updating here well?

);
expect(result.headerFormatter.format(500)).toBe('$500');
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great!

Copy link
Contributor

@geido Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments

Copy link
Contributor

@geido Ephemeral environment spinning up at http://44.247.250.79:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.

@Antonio-RiveroMartnez
Copy link
Member

Hey! The suffix is working as expected, however, when you set a subtitle, and you remove it, it's not clearing it up:

Screen.Recording.2025-04-23.at.4.09.00.PM.mov

Copy link
Contributor

@Antonio-RiveroMartnez Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments

Copy link
Contributor

@Antonio-RiveroMartnez Ephemeral environment spinning up at http://34.221.106.45:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, subheader and subtitle working as expected

Screen.Recording.2025-04-23.at.8.42.43.PM.mov

@Vitor-Avila
Copy link
Contributor

Performed below manual tests on my end:

  1. Spin up Superset from sha/commit 164a07e2be7854520070a7d845eec449405c4840 (last one before the PR that introduced subtitle - ref).
  2. Created 5 Big Numbers (one for each subheader font size) and added them to a dashboard.
  3. Did the same with the Big Number and Trendline chart type.
  4. Checked out to commit d75ff9e784ca571e8498febb3b492874118312c8 (the one introducing subtitles - ref).
  5. Validated that the subheader text have disappeared for the Big Numbers. Big Numbers with Trendline were still ok.
  6. Created 5 more Big Numbers using the new schema (with subtitle) and added to the same dashboard.
  7. Checked out to commit 41402617970368f0b14ff4e7acc1d271d5bcdd89 (the one that fixes the missing headers - ref). Validated that the Big Numbers are now showing the headers. Big Number with Trendline no longer show the subtitle. Also, the subtitle font sizes would show correct in the dashboard, but when accessing the charts in Explore they would always show up as Small (default value).
  8. Checked out to this PR. Validated that:
  • Subheaders for Big Numbers with Trendlines are back. ✅
  • Their font size is showing correctly both in charts and dashboards. ✅
  • The subtitle for Big Numbers appear duplicated: 🔴
image - Accessing the chart in Explore does not show the subtitle content (the subtitle size is also not correct): 🔴 image

@Vitor-Avila
Copy link
Contributor

@LevisNgigi my last comment was longer just to highlight the testing scenarios and flows, but to summarize, these are the remaining issues:

  • Big Numbers created prior to the subtitle PR show the subheader text duplicated.
  • Accessing the chart directly in Explore does not carry over the subtitle config (both text and size).

To easily repro this:

  1. Spin up Superset in dev mode.
  2. Check out to commit 164a07e2be7854520070a7d845eec449405c4840.
  3. Create a dashboard including one Big Number for each subheader size available. For example:
image 4. Checkout to this branch. 5. Refresh the dashboard: image 6. Accessing a chart from this dashboard does not show the subtitle config: image

Let me know if you have any questions!

@LevisNgigi
Copy link
Contributor Author

@LevisNgigi my last comment was longer just to highlight the testing scenarios and flows, but to summarize, these are the remaining issues:

  • Big Numbers created prior to the subtitle PR show the subheader text duplicated.
  • Accessing the chart directly in Explore does not carry over the subtitle config (both text and size).

To easily repro this:

  1. Spin up Superset in dev mode.
  2. Check out to commit 164a07e2be7854520070a7d845eec449405c4840.
  3. Create a dashboard including one Big Number for each subheader size available. For example:

image 4. Checkout to this branch. 5. Refresh the dashboard: image 6. Accessing a chart from this dashboard does not show the subtitle config: image
Let me know if you have any questions!

@Vitor-Avila Thanks for the thorough testing and concise feedback with repro steps.The steps were super helpful! I’ve fixed the subtitle duplication issue for Big Number charts. However, the issue where legacy charts (those created with subheader only) don’t show the subtitle content or correct size in Explore is still pending. Mapping the control to subheader brings back the value in explore and configs are restored, but it prevents the subtitle from being fully clearable, which isn’t ideal.Since subheader is also used as the comparison suffix in Big Number with Trendline, a simple migration isn’t straightforward I think.So wondering the best way forward.

@Vitor-Avila
Copy link
Contributor

@LevisNgigi glad to help and excited we're making progress here! 🙌

hmm could we make the migration dynamic based on the viz type? If it's a Big Number migrate subheader to subtitle and subheaderFontSize to subtitleFontSize, if Big Number with Trendline don't do it? I believe we can differentiate the two via their params, right? Ideally this migration could happen on the fly by the frontend.

Let me know if that makes sense/is possible -- I'm not super close to our frontend logic so it's totally possible that this wouldn't work/isn't possible.

Comment on lines 782 to 802
if (
form_data.viz_type === 'big_number_total' &&
slice?.form_data?.subheader &&
(!controls.subtitle?.value || controls.subtitle.value === '')
) {
controls.subtitle = {
...controls.subtitle,
value: slice.form_data.subheader,
};
}
if (
form_data.viz_type === 'big_number_total' &&
slice?.form_data?.subheader_font_size &&
(!controls.subtitle_font_size?.value ||
controls.subtitle_font_size.value === '')
) {
controls.subtitle_font_size = {
...controls.subtitle_font_size,
value: slice.form_data.subheader_font_size,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting this change for two reasons:

  • It moves the second change (controls.subtitle_font_size = slice.form_data.subheader_font_size) as part of the first if block. This is mostly because if the chart has a subheader config and does not have a subtitle config, then subheader_font_size should be the source of truth. For safety, just checking if slice?.form_data?.subheader_font_size exists.
  • In the current implementation, !controls.subtitle_font_size?.value is evaluated. I believe controls.subtitle_font_size always gets a default value, so that second if would never really execute and instead the old subheader ends up with the default size.
Suggested change
if (
form_data.viz_type === 'big_number_total' &&
slice?.form_data?.subheader &&
(!controls.subtitle?.value || controls.subtitle.value === '')
) {
controls.subtitle = {
...controls.subtitle,
value: slice.form_data.subheader,
};
}
if (
form_data.viz_type === 'big_number_total' &&
slice?.form_data?.subheader_font_size &&
(!controls.subtitle_font_size?.value ||
controls.subtitle_font_size.value === '')
) {
controls.subtitle_font_size = {
...controls.subtitle_font_size,
value: slice.form_data.subheader_font_size,
};
}
if (
form_data.viz_type === 'big_number_total' &&
slice?.form_data?.subheader &&
(!controls.subtitle?.value || controls.subtitle.value === '')
) {
controls.subtitle = {
...controls.subtitle,
value: slice.form_data.subheader,
};
if (slice?.form_data?.subheader_font_size) {
controls.subtitle_font_size = {
...controls.subtitle_font_size,
value: slice.form_data.subheader_font_size,
};
}
}

@Vitor-Avila
Copy link
Contributor

@LevisNgigi thank you so much for taking the time to implement these fixes! 🙏 I tested the flow again and:

  • Big Numbers with Trendline seem to be working properly. ✅
  • Existing Big Numbers are no longer showing both subheader and subtitle in the dashboard view. Just one is displayed. ✅
  • Accessing these Big Numbers in Explore shows a single entry as well. ✅
  • Accessing these Big Numbers in Explore defaults the subtitle size to the default value (Small) as opposed to respecting the old value from subheader. 🔴

I suggested a potential fix for this remaining issue, but I didn't want to commit it as I want your thoughts on it first. If you're comfortable with it, feel free to push it to this branch and I can do one final round of tests. 🙌

Copy link
Contributor

@Vitor-Avila Vitor-Avila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Vitor-Avila Vitor-Avila merged commit 6a586fe into apache:master Apr 25, 2025
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants