-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix charts using chart.js #13212
Conversation
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
||
// chart options config | ||
const chartOptions = { | ||
// chart styles | ||
barThickness: 38, |
There was a problem hiding this comment.
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
aspectRatio: aspectRatioValue, | ||
maintainAspectRatio: true, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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} /> |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
… add rtl support, improve type safety, and add story
Looks good, @nhsz this targets your branch though so I'll let you merge when ready |
Description
Tackles issues detected while testing the chart.js migration.
Home page charts
Energy consumption chart
aspectRatio
unset given that we want the chart to adapt to its parent sizeAdded stories for both.
Related PR
#12952