Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

expenses chart component main

amine takdentiโ€ข 330

@aminetakdenti

Desktop design screenshot for the Expenses chart component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


welcom feedback

Community feedback

Account Deleted

Hello amine, congrats on completing the the bar chart component. Styles are really good as well as the responsiveness. The project is already well coded so I just would like to notice the following about the JS logic.

getApi() function holds all the logic. Once the response is parsed you could abstract the logic for manipulating the DOM into another function, passing as argument the reponse parsed. That would made your logic much cleaner.

function getApi() {
  fetch("data.json")
    .then((data) => data.json())
    .then((json) => {
         createBarChart(json);
    })
    .catch((err) => err);
}

function createBarChart(json) {
// Here the code for DOM manipulation.
}

Another point is using the property style when manipulating the DOM. While it works is not a best practice because it generates inline styles for the HTML elements. Changing styles should be approached adding, removing or replacing classes. So instead of this:

 daysInfo.item(max).style.backgroundColor = `hsl(186, 34%, 60%)`;

This should be applied:

 daysInfo.item(max).classList.add("example-class");

In your css would be .example-class { background-color: hsl(186, 34%, 60%) }

Hope this helps, happy coding and I see you around!

Marked as helpful

1

amine takdentiโ€ข 330

@aminetakdenti

Posted

@alexcumplido Thank you for your advice that was relly helpfull๐Ÿ‘Œ๐Ÿ‘Œ๐Ÿ‘Œ

1

Account Deleted

@aminetakdenti you're welcome! Hope to see more projects : )

Marked as helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord