Skip to content
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

feat(formatting): Add memory units adaptive formatter to format bytes #30559

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mkopec87
Copy link

@mkopec87 mkopec87 commented Oct 9, 2024

Add new memory units adaptive formatter to format bytes units into kB, MB, GB, etc.

SUMMARY

Memory unit (bytes) is typically formatted into kB (kilobytes), MB (megabytes), etc.
Superset formatting options don't enable adaptive formatting with proper unit naming in case of bytes values.
There are two most commonly used multi-byte unit types (according to wikipedia), this PR implements them both.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

image

TESTING INSTRUCTIONS

  1. Create a Chart, for example Table, with at least one numeric data column.
  2. Edit the Chart, in the "Customize" tab select one of "Memory in bytes" options for formatting of your numeric column.

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

@mkopec87
Copy link
Author

mkopec87 commented Oct 9, 2024

I've created a discussion for this PR as well: #30558

@mkopec87 mkopec87 marked this pull request as ready for review October 9, 2024 12:37
@dosubot dosubot bot added the change:frontend Requires changing the frontend label Oct 9, 2024
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

This is a great feature, and one that many have been looking forward to seeing. In general this looks good, but would you be able to add some unit tests?

@mkopec87
Copy link
Author

@villebro , sure thing, let me give it a try :) I never wrote any Javascript before, therefore happy to get some feedback :)
CI setup is very useful here.

- Make decimals option a parameter of MemoryFormatter
- Handle negative values in MemoryFormatter
- Handle values exceeding maximal unit value in MemoryFormatter
@pull-request-size pull-request-size bot added size/L and removed size/M labels Oct 11, 2024
@mkopec87
Copy link
Author

@villebro I added unit tests and fixed some bugs on the way :) Let me know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend packages size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants