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

✨ (line chart) set y-axis min default to 0 #4080

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Oct 24, 2024

Resolves #3797

Summary

Makes 0 the new default minimum value for the y-axis of line charts

Details

About the default Grapher config

  • With these changes, the default of yAxis.min depends on the chart type (0 for line charts, auto for others). As a result, yAxis.min can't be included in the default base layer (since there isn't a single default value that should apply to all configs)
  • I removed the default value for both the x-axis and the y-axis because I want to keep using one definition for the axis. I haven't found a way to compose the JSON schema such that I can keep the axis definition in one place and change the default min value of y-axis only
  • Since we changed the default grapher config, we have to re-compute the full configs of all charts

About the Grapher/config interface

  • The auto value parsed from the config used to be translated to undefined for Grapher, which told Grapher to infer the min/max value from the data
  • With these changes, the auto value is translated to Infinity, which also means "infer from data", and having no value triggers the default behaviour, which is usually "auto" behaviour but is overwritten to be 0 for line charts

About the admin

  • The admin doesn't say 0 for line charts if the default behaviour is used because the value is actually undefined/Infinity

SVG tester

The SVG tester updates are technically correct. I'll re-export configs for the SVG tester next week after removing the default config layer.

To do

@owidbot
Copy link
Contributor

owidbot commented Oct 24, 2024

Quick links (staging server):

Site Admin Wizard Docs

Login: ssh owid@staging-site-line-chart-yaxis-min-viz

SVG tester:

Number of differences (default views): 31 (25d0a4) ❌
Number of differences (all views): 0 ✅

Edited: 2024-11-06 16:05:32 UTC
Execution time: 1.20 seconds

@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch 2 times, most recently from 5f8a77a to ffdc35c Compare October 30, 2024 17:01
@sophiamersmann sophiamersmann changed the base branch from master to fix-explorer-config-merge October 30, 2024 17:01
@sophiamersmann sophiamersmann force-pushed the fix-explorer-config-merge branch from 3597b31 to e07f64a Compare October 31, 2024 09:56
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from ffdc35c to 34a35c4 Compare October 31, 2024 09:56
@sophiamersmann sophiamersmann force-pushed the fix-explorer-config-merge branch from e07f64a to c60c2c5 Compare October 31, 2024 10:19
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from 34a35c4 to c95ccf1 Compare October 31, 2024 10:19
@sophiamersmann sophiamersmann force-pushed the fix-explorer-config-merge branch from c60c2c5 to 7ff306f Compare October 31, 2024 11:27
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from f9cf121 to d234fe8 Compare October 31, 2024 11:27
@sophiamersmann sophiamersmann force-pushed the fix-explorer-config-merge branch from 7ff306f to 7d455e6 Compare October 31, 2024 16:00
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from 2056540 to f107534 Compare October 31, 2024 16:00
@sophiamersmann sophiamersmann force-pushed the fix-explorer-config-merge branch from 7d455e6 to adf0264 Compare October 31, 2024 16:12
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from f107534 to 9e86996 Compare October 31, 2024 16:12
@sophiamersmann sophiamersmann force-pushed the fix-explorer-config-merge branch from adf0264 to a3b1e38 Compare October 31, 2024 16:13
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch 3 times, most recently from 7e9094f to 635477e Compare October 31, 2024 18:32
@sophiamersmann sophiamersmann force-pushed the fix-explorer-config-merge branch from a3b1e38 to fce4f27 Compare November 1, 2024 10:11
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from 635477e to 27aad3d Compare November 1, 2024 10:11
@sophiamersmann sophiamersmann marked this pull request as ready for review November 1, 2024 10:13
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from 27aad3d to f801620 Compare November 1, 2024 10:25
Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

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

Nice!

One thing I didn't entirely find out, but I think I got a sense: Existing charts stay unchanged in this, right? I.e., the migration makes it so the "effective chart diff" is empty?

public async down(): Promise<void> {}
}

const defaultGrapherConfig = {
Copy link
Member

Choose a reason for hiding this comment

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

If I understand this correctly, then this is the default config before this PR was merged, right?

If that's the case, then let's make this more explicit - either in the name or in a comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh shoot, I copy-pasted the wrong config! This should just be the default config as it exists on this branch. I copied it over (instead of importing) because I realised that relying on the default config version of the code that is running the migration is a bit dangerous (because we really do need this specific version of the default config). Sorry for the confusion!

So, the default config we're working with doesn't have a default value for yAxis.min. Then, the gist of the migration is:

  • If a chart relied on the default for yAxis.min being auto, add yAxis.min=auto to its patch config to make this explicit
  • Then recompute the full config using the new default config
  • The full config should thus be unchanged (but the patch config of a chart might have been changed)

Before reading your comment, I was testing an upstream PR upstream and I couldn't make sense of some of the chart diffs I was seeing. I'm pretty sure this is the reason – so thanks for spotting it! It probably would have taken ages to figure it out 🫠

Base automatically changed from fix-explorer-config-merge to master November 6, 2024 15:26
@sophiamersmann sophiamersmann force-pushed the line-chart-yaxis-min-viz branch from 9bf41a6 to 5da7000 Compare November 6, 2024 15:46
@sophiamersmann sophiamersmann merged commit 3db6918 into master Nov 8, 2024
22 checks passed
@sophiamersmann sophiamersmann deleted the line-chart-yaxis-min-viz branch November 8, 2024 10:18
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.

Use default yAxisMin value of 0
3 participants