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

🎉 (grapher) round to significant figures / TAS-537 #3709

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Jun 12, 2024

Adds support for rounding to significant numbers, resolves #1851

Summary

  • Adds variable.display.roundingMode and variable.display.numSignificantFigures
    • The roundingMode is one of decimalPlaces or significantFigures (with decimalPlaces being the default)
    • If the roundingMode is decimalPlaces, we look at numDecimalPlaces; if the roundingMode is significantFigures, we look at numSignificantFigures
  • Rounding to significant figures relies on d3's r mode ("decimal notation, rounded to significant digits"); when rounding to sig figs, trailing zeroes are always shown
  • In essence, values rounded to sig figs appear everywhere expect for the table, where we use fixed-point notation

Details

  • Sig fig rounded values appear in all tooltips
    • If they do, the tooltip displays a note that says "Values are rounded to X significant figures" or "Values are rounded to X or Y significant figures" (if the tooltip displays values that are rounded to different numbers of sig figs)
  • Sig fig rounded values appear in the chart area; this includes:
    • Discrete bar charts
    • Stacked discrete bar charts
    • Slope charts
    • Scatter plots (value labels are used in time scatters when scatterPointLabelStrategy is set to x or y)
  • Sig figs appear in the entity selector for consistency
  • Sig figs don't appear in the data table, here we always use fixed-point notation (note that numDecimalPlaces is respected here)

Caveats

  • Discrete bar charts and slope charts don't have tooltips, which means that we don't currently mention anywhere that we use significance rounding

Testing

To do

  • Let Mojmir know that you added variable.display.roundingMode and variable.display.numSignificantFigures

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @sophiamersmann and the rest of your teammates on Graphite Graphite

@sophiamersmann sophiamersmann changed the title 🔨 add roundingMode to variable display 🔨 add roundingMode to variable display / TAS-537 Jun 12, 2024
Copy link

@owidbot
Copy link
Contributor

owidbot commented Jun 12, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-add-rounding-mode

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-06-14 08:56:02 UTC
Execution time: 1.16 seconds

@sophiamersmann sophiamersmann changed the title 🔨 add roundingMode to variable display / TAS-537 🎉 (grapher) round to significant figures / TAS-537 Jun 13, 2024
@sophiamersmann sophiamersmann force-pushed the add-rounding-mode branch 11 times, most recently from b2f53b7 to a3502f6 Compare June 19, 2024 07:06
@sophiamersmann sophiamersmann marked this pull request as ready for review June 19, 2024 09:03
@sophiamersmann sophiamersmann requested a review from danyx23 June 19, 2024 09:04
Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

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

Very nice work! I had a couple of minor comments but nothing major. I didn't look in too much detail at the rendering code for the different charts but played a little with it and it all looks good.

@sophiamersmann
Copy link
Member Author

Thank you for the review! Being able to type 1_000_000 is neat 🙌🏻

@sophiamersmann sophiamersmann merged commit 5150fb2 into master Jun 27, 2024
21 checks passed
@sophiamersmann sophiamersmann deleted the add-rounding-mode branch June 27, 2024 14:54
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.

Support negative rounding and rounding by significant figures
3 participants