Skip to content

Introducing the Expenses Chart Component, your ultimate expenses tracker! Experience the optimal layout on any device screen size and interact with hover states for all elements on the page. Dive deeper into your financial insights with the Expenses Chart Component today!

License

Notifications You must be signed in to change notification settings

all-my-frontend-mini-projects/Expenses-chart-component_frontend_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expenses Chart Component

Welcome! 👋

Table of contents

Overview

The challenge

The challenge is to create an Expenses Chart Component, part of a website designed to calculate and track expenses.

Users should be able to

  • View the bar chart.
  • Hover over individual bars to see the correct amounts for each day.
  • See the current day's bar highlighted in a different color.
  • View the optimal layout for the content depending on their device's screen size.
  • See hover states for all interactive elements on the page.
  • A bonus challenge is to dynamically generate bars based on the data provided in a local JSON file.

How to setup the project

To set up the project locally, follow these steps:

  1. Clone the repository using GitHub Desktop or Git Bash:
    git clone https://github.com/SartHak-0-Sach/Expenses-chart-component_frontend_project.git
  2. Open the project folder in your code editor.
  3. Run the project using a live server extension or deploy it using Netlify, Vercel, or another web hosting and deployment service.

Screenshot

Design Preview

Links

My process

Built with

  • HTML5
  • CSS3
  • JavaScript

You will find all the required assets in the /images folder. The assets are already optimized.

There is also a style-guide.md file containing the information you'll need, such as color palette and fonts.

What I learned

Through this project I learnt how one makes a website/web app dynamic with different content customized/personalized for each and every user using math operations in JavaScript as shown-

function populateBars(jsonArr) {
    const maxAmount = jsonArr.reduce(
        (max, obj) =>
            Number(max) < Number(obj.amount) ? Number(obj.amount) : Number(max),
        0
    );

    let height;
    if (window.innerWidth >= 700) {
        height = (ratio) => `${ratio * 150}px`;
    } else {
        height = (ratio) => `${(150 / 375) * ratio * 100}vw`;
    }

    for (const obj of jsonArr) {
        const bar = document.querySelector(`#${obj.day}`);
        const ratio = obj.amount / maxAmount;
        bar.style.height = height(ratio);
        bar.style.transitionDuration = `${ratio * 2}s`;
        bar.dataset.amount = `$${obj.amount}`;
    }

    // Highlight current day with a different color
    const weekDayIndex = (new Date().getDay() - 1 + 7) % 7;
    const currBar = document.querySelectorAll(".bar")[weekDayIndex];
    currBar.style.backgroundColor = cyan;
    currBar.onmouseover = () => (currBar.style.backgroundColor = fadedCyan);
    currBar.onmouseout = () => (currBar.style.backgroundColor = cyan);
}

Continued development

The continuously learning journey of a programmer never ends. This project made me realize that there are many concepts that I need to work upon including fundamentals like flex-box and its properties, to more complex concepts like working with fetch and async await in javascript. These areas are some that I think I need to work more upon in the upcoming future as they highlight some of the most significant regions of web development that are important for every developer to know of.

These key points mentioned here will help me grow accountable and consistent towards improving at writing good quality code and be a successful full stack developer one day.

Useful resources

  • Harkirat Singh course notes - I have added notes of all lectures along with code and lecture insights of all weeks along with bonus lectures to help you all as much as I can.
  • My development code and notes - These are my notes that I made while working on my development skills in initial days and did these courses. Make sure to star the repository if you like it.✨💫
  • mdn documentation - This is an amazing article which helped me finally understand promises, async and await syntax. I'd recommend it to anyone still learning this concept.

Author

Sarthak Sachdev

Acknowledgments

I feel like the solutions provided on the website and the continuous doubt solving by industry experts on discord for free is something that is unmatched by anyone else and need to be acknowledged for their efforts in improving me as a developer by suggesting the best practices in your respective tech stack.

Got feedback for me?

I love receiving feedback! I am always looking to improve my code and take up new innovative ideas to work upon. So if you have anything you'd like to mention, please email 'hi' at saarsaach30[at]gmail[dot]com.

If you found this project helpful, consider sharing it with others to spread the knowledge!

Happy budgeting! 💰🚀

About

Introducing the Expenses Chart Component, your ultimate expenses tracker! Experience the optimal layout on any device screen size and interact with hover states for all elements on the page. Dive deeper into your financial insights with the Expenses Chart Component today!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published