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

Refactor charts code #1169

Closed
wants to merge 7 commits into from
Closed

Conversation

Bhavyajain21
Copy link

Description

This fixes #1111
/claim #1111

I've added two new useCallback hooks, handleDownloadChartPng and handleDownloadCsv, to handle the download of PNG and CSV files respectively. These hooks are more efficient because they have a stable reference, preventing unnecessary re-renders.

Additionally, the rendering logic for the chart component has been optimized. We only render either a Bar or Line chart based on the config.type property, avoiding unnecessary conditional rendering.

These changes aim to optimize performance and improve code readability.

While these optimizations are contributing to better load time balance between Chrome and Firefox, it's important to note that browser performance can be influenced by various factors beyond the control of the application code. Factors such as browser engine differences, hardware capabilities, network conditions, and browser extensions can all impact performance.

@algora-pbc algora-pbc bot mentioned this pull request Mar 20, 2024
@Bhavyajain21
Copy link
Author

Bhavyajain21 commented Mar 20, 2024

Please review @ericboucher

@Bhavyajain21 Bhavyajain21 changed the title code refactoring fix: Charts load time - code refactoring Mar 20, 2024
@ericboucher
Copy link
Collaborator

@Bhavyajain21 Thanks for your work, could you make sure that the linter and type checks are passing please? As a bonus this will create a QA deploy automatically.

@Bhavyajain21
Copy link
Author

@Bhavyajain21 Thanks for your work, could you make sure that the linter and type checks are passing please? As a bonus this will create a QA deploy automatically.

@ericboucher, yes I have been trying to do that but the approcahes haven't worked much from my side.

@Bhavyajain21
Copy link
Author

Thanks for the commit @ericboucher

@Bhavyajain21
Copy link
Author

@ericboucher Can you please review this?

@ericboucher
Copy link
Collaborator

@Bhavyajain21 thanks for your work, I will try to finish my review soon but it's a bit hard to QA.
I see how the refactoring makes the code slightly simpler but I do not see how this would solve the performance issue we were seeing.
Aditionnally, the code was not working before my commit so I am not sure to what extent you were able to test this. Have you been able to test a before/after load time on Chrome vs FIrefox?

.map(row => row[config.category]);
}, [chartRange, config.category, header, indices, tableRows, transpose]);
const labels = useMemo(() => {
return transpose
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Bhavyajain21 in some cases in this PR you are changing to ternary tetss and in others you are changing a ternary to an if statement, can you explain the rationale behind these changes?

}, [
colors,
tableRows,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see a lot of order changes in the dependency arrays, is there a specific reason or logic? If not, it makes the code changes a bit more noisy and should be avoided imho :)

@ericboucher ericboucher changed the title fix: Charts load time - code refactoring Refactor charts code Mar 27, 2024
@Bhavyajain21
Copy link
Author

Bhavyajain21 commented Mar 27, 2024

Hey @ericboucher, I've been busy from past few days. Sorry for the delayed response.

I currently don't have my system with me. I need to review the code to get the reviews resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charts load time
2 participants