Skip to content

Commit

Permalink
Merge pull request #242 from ORNL-AMO/issue-235
Browse files Browse the repository at this point in the history
Issue 235
  • Loading branch information
nbintertech authored Feb 29, 2024
2 parents 9f9bf18 + 67427f2 commit 8f63be2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ export class Dashboard extends PureComponentIgnoreFuncs<DashboardProps> {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
});
const threeDecimalFormatter = Intl.NumberFormat('en-US', {
minimumFractionDigits: 1,
maximumFractionDigits: 3,
});

const carbonSavingsPercent = this.props.carbonSavingsPercent * 100;
const carbonSavingsFractionValue = clampRatio(this.props.carbonSavingsPercent, 1);
const carbonSavingsFormatted = `${carbonSavingsPercent.toFixed(1)}%`;

const naturalGasEmissionRateFormatted: string = singleDecimalFormatter.format(this.props.naturalGasEmissionsPerMMBTU);
const electricityEmissionRateFormatted: string = singleDecimalFormatter.format(getElectricityEmissionsFactor(this.props.currentGameYear, this.props.gameYearInterval, this.props.gameYearDisplayOffset));
const hydrogenEmissionRateFormatted: string = singleDecimalFormatter.format(this.props.hydrogenEmissionsPerMMBTU);
const naturalGasEmissionRateFormatted: string = threeDecimalFormatter.format(this.props.naturalGasEmissionsPerMMBTU);
const electricityEmissionRateFormatted: string = threeDecimalFormatter.format(getElectricityEmissionsFactor(this.props.currentGameYear, this.props.gameYearInterval, this.props.gameYearDisplayOffset));
const hydrogenEmissionRateFormatted: string = threeDecimalFormatter.format(this.props.hydrogenEmissionsPerMMBTU);

const emissionsFromNaturalGasFormatted: string = singleDecimalFormatter.format(this.props.naturalGasEmissionsPerMMBTU * this.props.naturalGasMMBTU / 1000);
const emissionsFromElectricityFormatted: string = singleDecimalFormatter.format((this.props.currentGameYear, this.props.gameYearInterval) * this.props.electricityUseKWh / 1000);
const emissionsFromElectricityFormatted: string = singleDecimalFormatter.format(getElectricityEmissionsFactor(this.props.currentGameYear, this.props.gameYearInterval, this.props.gameYearDisplayOffset) * this.props.electricityUseKWh / 1000);
const emissionsFromHydrogenFormatted: string = singleDecimalFormatter.format(this.props.hydrogenEmissionsPerMMBTU * this.props.hydrogenMMBTU / 1000);

const electricityCost = noDecimalsFormatter.format(this.props.electricityCostPerKWh * this.props.electricityUseKWh);
Expand Down

0 comments on commit 8f63be2

Please sign in to comment.