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 charts using chart.js #13212

Merged
merged 6 commits into from
Jun 24, 2024
Merged

Fix charts using chart.js #13212

merged 6 commits into from
Jun 24, 2024

Conversation

pettinarip
Copy link
Member

@pettinarip pettinarip commented Jun 20, 2024

Description

Tackles issues detected while testing the chart.js migration.

Home page charts

  • app crashing on production build when user changes the range period
  • disabled labels because for some reason, some times, they were displayed even though we are not using labels in this case

Energy consumption chart

  • better responsive styles (docs) - left the aspectRatio unset given that we want the chart to adapt to its parent size
  • adjust chart height for different resolutions
  • rtl support
  • fixed a few typing issues

Added stories for both.

Related PR

#12952

@github-actions github-actions bot added content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies documentation 📖 Change or add documentation tooling 🔧 Changes related to tooling of the project translation 🌍 This is related to our Translation Program labels Jun 20, 2024
@pettinarip pettinarip changed the base branch from performance-chartjs to dev June 20, 2024 08:01
Copy link

netlify bot commented Jun 20, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit ffd6e41
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/6673e2577256170008da6a2d
😎 Deploy Preview https://deploy-preview-13212--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 42 (🟢 up 4 from production)
Accessibility: 92 (no change from production)
Best Practices: 83 (🔴 down 9 from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@pettinarip pettinarip changed the title Fix charts Fix charts using chart.js Jun 20, 2024
@pettinarip pettinarip changed the base branch from dev to performance-chartjs June 20, 2024 11:31

// chart options config
const chartOptions = {
// chart styles
barThickness: 38,
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved these to the dataset to avoid type errors

Comment on lines -171 to -172
aspectRatio: aspectRatioValue,
maintainAspectRatio: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the aspectRatio and leave it to adapt automatically to the container size.

maintainAspectRatio: false,
layout: {
padding: {
top: 10,
Copy link
Member Author

Choose a reason for hiding this comment

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

Added some padding because the label was cut off on small resolutions

@@ -184,7 +196,7 @@ export const GridItem = ({ metric }: GridItemProps) => {
</Box>
{hasData && (
<Box position="absolute" insetInline="0" bottom={7} height="60%">
<Line options={chartOptions} data={chartData} updateMode="none" />
<Line options={chartOptions} data={chartData} />
Copy link
Member Author

Choose a reason for hiding this comment

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

Minor: removed this to have an animation when you update the data.

data: hasData
? dataValues.slice(dataValues.length - filteredRange!.length)
: [],
data: filteredRange.map((item) => item.value),
Copy link
Member Author

Choose a reason for hiding this comment

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

Simplified this logic since I thought it was related to the production error. I left it because it looks simpler to read.

@wackerow
Copy link
Member

Looks good, @nhsz this targets your branch though so I'll let you merge when ready

@nhsz nhsz merged commit d723cd2 into performance-chartjs Jun 24, 2024
4 of 6 checks passed
@nhsz nhsz deleted the fix-charts branch June 24, 2024 13:35
This was referenced Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies documentation 📖 Change or add documentation tooling 🔧 Changes related to tooling of the project translation 🌍 This is related to our Translation Program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants