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

fix(web): add chart fixes #598

Merged
merged 11 commits into from
Nov 8, 2024
Merged

fix(web): add chart fixes #598

merged 11 commits into from
Nov 8, 2024

Conversation

PJColombo
Copy link
Member

@PJColombo PJColombo commented Oct 15, 2024

Checklist

  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

It adds the following fixes to the charts on the /stats page:

  • Display full amounts on the tooltip
  • Display amounts without units on the y-axis; moving the unit being used to the chart's title
  • Fix an issue where the metric cards was being rendered more than necessary

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

BEFORE
image

image

AFTER
image

image

Resolved an issue where the increment animation was being triggered n times, where n is the value of the metric
…e axis + show full (non-compacted) amounts in tooltips + align chart's grid positioning
Copy link

changeset-bot bot commented Oct 15, 2024

🦋 Changeset detected

Latest commit: 78bc1e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@blobscan/web Patch
@blobscan/eth-units Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blobscan-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2024 3:15pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
blobscan-docs ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 3:15pm
blobscan-gnosis ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 3:15pm
blobscan-holesky ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 3:15pm
blobscan-mainnet ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 3:15pm
blobscan-sepolia ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 3:15pm

Copy link
Contributor

github-actions bot commented Oct 15, 2024

📦 Next.js Bundle Analysis for @blobscan/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 332.95 KB (🔴 +87.33 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

New Pages Added

The following pages were added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/block_neighbor 251 B 333.2 KB 95.20%
/stats 348 KB 680.96 KB 194.56%

Eight Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/ 353.07 KB 686.02 KB 196.01% (🟢 -4.65%)
/address/[address] 28.54 KB 361.49 KB 103.28% (🟢 -4.34%)
/blob/[hash] 29.22 KB 362.18 KB 103.48% (🟢 -3.77%)
/blobs 79.05 KB 412 KB 117.71% (🟡 +13.21%)
/block/[id] 14.9 KB 347.85 KB 99.39% (🟢 -3.99%)
/blocks 76.75 KB 409.7 KB 117.06% (🟡 +13.19%)
/tx/[hash] 17.3 KB 350.25 KB 100.07% (🟡 +1.16%)
/txs 76.25 KB 409.21 KB 116.92% (🟡 +11.18%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.14%. Comparing base (f93f96f) to head (78bc1e0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #598   +/-   ##
=======================================
  Coverage   89.14%   89.14%           
=======================================
  Files         155      155           
  Lines       10492    10492           
  Branches     1187     1187           
=======================================
  Hits         9353     9353           
  Misses       1139     1139           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Hide y-axis byte units and display it on chart title
- Fix displayed byte unit on y-axis
@@ -2,6 +2,9 @@ const ETH_UNITS = { wei: 0, Gwei: 9, ether: 18 };

export type EthAmount = string | number | bigint;
export type EtherUnit = keyof typeof ETH_UNITS;
export type FormatOptions = Partial<{
Copy link
Member

Choose a reason for hiding this comment

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

Now that we sometimes need formatWei and prettyFormatWei without a unit, I see why this option was added. However, I think a better approach would be to remove the unit display handling from these functions altogether and keep them focused purely on number formatting. Since we already pass the unit to these functions, we can append it directly where needed, like this:

`${formatWei(value, unit) ${unit}`
`${prettyFormatWei(value, unit) ${unit}`

By keeping the function inputs minimal, we reduce the risk of a combinatorial explosion from too many options, which makes the function easier to test and maintain overall.

Copy link
Member Author

Choose a reason for hiding this comment

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

The way I see it: formatting involves transforming a value into a more user-friendly and presentable format, which includes displaying the units.

If you just need to convert an amount, you can use convertWei.

To reduce test complexity, we can focus on testing each option separately and ensure the output is correct. For example: when testing the unit display option, we only need to verify that it works correctly, regardless of which unit is being targeted.

apps/web/src/utils/number.ts Outdated Show resolved Hide resolved
If no unit is provided, automatically determine and use the most appropriate unit
@PJColombo PJColombo merged commit 05bdc1d into main Nov 8, 2024
14 checks passed
@PJColombo PJColombo deleted the fix/web/chart-fixes branch November 8, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants