Skip to content

Conversation

bernardobelchior
Copy link
Member

@bernardobelchior bernardobelchior commented May 2, 2025

Add a population pyramid demo with data for South Korea in 2022.

image

Data source: KOSIS.

Copy link

github-actions bot commented May 2, 2025

Thanks for adding a type label to the PR! 👍

@bernardobelchior bernardobelchior force-pushed the add-population-pyramid-demo branch from 6d17265 to a060d50 Compare May 2, 2025 08:20
@bernardobelchior bernardobelchior added docs Improvements or additions to the documentation. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: charts Changes related to the charts. labels May 2, 2025
@mui-bot
Copy link

mui-bot commented May 2, 2025

Deploy preview: https://deploy-preview-17652--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against 9c64248

Copy link

codspeed-hq bot commented May 2, 2025

CodSpeed Performance Report

Merging #17652 will not alter performance

Comparing bernardobelchior:add-population-pyramid-demo (9c64248) with master (1ed98ca)

Summary

✅ 8 untouched benchmarks

Comment on lines 2 to 3
import { BarChart } from '@mui/x-charts/BarChart';
import { Stack, Typography } from '@mui/material';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import { BarChart } from '@mui/x-charts/BarChart';
import { Stack, Typography } from '@mui/material';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import { BarChart } from '@mui/x-charts/BarChart';

]}
xAxis={[
{
valueFormatter: (d: number) => `${numberFormatter.format(Math.abs(d))}`,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the axis will be easier to read

Suggested change
valueFormatter: (d: number) => `${numberFormatter.format(Math.abs(d))}`,
valueFormatter: (d: number) => `${numberFormatter.format(Math.abs(d) / 1000 )}k`,

Copy link
Member Author

Choose a reason for hiding this comment

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

Used k for thousands and M for million:

image

Comment on lines 47 to 63
const suffixes = [
{ value: 1e6, symbol: 'M' },
{ value: 1e3, symbol: 'k' },
];

const suffix = suffixes.find((s) => Math.abs(number) >= s.value);

if (!suffix) {
return new Intl.NumberFormat('en-US').format(number);
}

const formattedValue = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 0,
maximumFractionDigits: 1,
}).format(number / suffix.value);

return formattedValue + suffix.symbol;
Copy link
Member

@alexfauquette alexfauquette May 2, 2025

Choose a reason for hiding this comment

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

I think you can get it with less effort ;)

Suggested change
const suffixes = [
{ value: 1e6, symbol: 'M' },
{ value: 1e3, symbol: 'k' },
];
const suffix = suffixes.find((s) => Math.abs(number) >= s.value);
if (!suffix) {
return new Intl.NumberFormat('en-US').format(number);
}
const formattedValue = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 0,
maximumFractionDigits: 1,
}).format(number / suffix.value);
return formattedValue + suffix.symbol;
return new Intl.NumberFormat('en-US', { notation: 'compact' }).format(number);

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Much better, thank you 😄

@bernardobelchior bernardobelchior merged commit d208a70 into mui:master May 2, 2025
22 checks passed
bernardobelchior added a commit to bernardobelchior/mui-x that referenced this pull request May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation. scope: charts Changes related to the charts. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants