Skip to content

Monthly CO2 emissions per transport are not displayed in my bar chart #720

Answered by Kheirah
donacrisante asked this question in Web
Discussion options

You must be logged in to vote

Okay, I see. Forget about my first answer, we'll keep the month array as is.

In total, you'll need to change several other things. First, adjust the function totalEmissionsPerTransport to consider that the fuel might be missing as is the case for transports like the plane.

const totalEmissionsPerTransport = (transport, fuel, month) =>
    Math.floor(
      entries
        .filter(
          (entry) => {
            const hasFuel = fuel ? true : false;
            const givenTransport = entry.transport === transport;
            const givenFuel = entry.fuel === fuel;
            const givenMonth = new Date(entry.date).getMonth() === month;
            return hasFuel ? (givenFuel && givenT…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Kheirah
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants