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

Production mode carbon emission graph's y-axis scale fixed #5312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrSeoD
Copy link
Contributor

@mrSeoD mrSeoD commented Apr 22, 2023

Issue

Incorrect axis labels in emissions chart (production mode) #5140

Description

The goal of this PR is to fix the y-axis scale of Carbon Emission graph under the Production Mode. Previously, as represented in the issue link, the y-axis values was completely off and do not match with actual values of graph. In order to fix it, when calling the function "getTotalElectricity(zoneData, displayByEmissions)" in useEmissionChartData.ts file, I had to change the second parameter to use "displayByEmissionsAtom" instead of mixMode.

Preview

image
As you can see in the picture, the y-axis is correctly scaled.

Double check

  • [N/A] I have tested my parser changes locally with poetry run test_parser "zone_key"
  • [DONE ] I have run pnpx prettier --write . and poetry run format to format my changes.

@tonypls
Copy link
Collaborator

tonypls commented Apr 24, 2023

Hi @mrSeoD,

Thanks for the work, it looks like there is an existing bug in the "getTotalElectricity" function and it's not named very well either.

With the fix it shows identical carbon emissions in consumption and production mode.

I think we should have two functions here, psuedocode below:

export function getTotalElectricity(zoneData: ZoneDetail, isProductionMode: boolean) {
  if (totalProduction == null) {
    return Number.NaN;
  }
  return isProductionMode
    ? productionValue
    : productionValue + zoneData.totalDischarge + zoneData.totalImport - zoneData.totalExport;
} 


export function getTotalEmissions(zoneData: ZoneDetail, isProductionMode: boolean) {
  if (zoneData.totalCo2Production == null) {
    return Number.NaN;
  }

  return isProductionMode
    ? zoneData.totalCo2Production
    : zoneData.totalCo2Production + zoneData.totalCo2Discharge + zoneData.totalCo2Import - zoneData.totalCo2Export;
}

@madsnedergaard
Copy link
Member

Hey @mrSeoD, any chance you could make the changes suggested by @tonypls so we can merge this PR? :)

@madsnedergaard madsnedergaard added the change requested A change was requested from the contributor label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change requested A change was requested from the contributor frontend 🎨
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants