Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions locales/en-US/app.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ TrackMemoryGraph--operations-since-the-previous-sample = operations since the pr
## consumption. The carbon dioxide equivalent represents the equivalent amount
## of CO₂ to achieve the same level of global warming potential.

# This is used in the tooltip when the power value uses the kilowatt unit.
# Variables:
# $value (String) - the power value at this location
TrackPower--tooltip-power-kilowatt = { $value } kW
.label = Power

# This is used in the tooltip when the power value uses the watt unit.
# Variables:
# $value (String) - the power value at this location
Expand All @@ -819,6 +825,14 @@ TrackPower--tooltip-power-watt = { $value } W
TrackPower--tooltip-power-milliwatt = { $value } mW
.label = Power

# This is used in the tooltip when the energy used in the current range uses the
# kilowatt-hour unit.
# Variables:
# $value (String) - the energy value for this range
# $carbonValue (string) - the carbon dioxide equivalent (CO₂e) value (kilograms)
TrackPower--tooltip-energy-carbon-used-in-range-kilowatthour = { $value } kWh ({ $carbonValue } kg CO₂e)
.label = Energy used in the visible range

# This is used in the tooltip when the energy used in the current range uses the
# watt-hour unit.
# Variables:
Expand All @@ -843,6 +857,14 @@ TrackPower--tooltip-energy-carbon-used-in-range-milliwatthour = { $value } mWh (
TrackPower--tooltip-energy-carbon-used-in-range-microwatthour = { $value } µWh ({ $carbonValue } mg CO₂e)
.label = Energy used in the visible range

# This is used in the tooltip when the energy used in the current preview
# selection uses the kilowatt-hour unit.
# Variables:
# $value (String) - the energy value for this range
# $carbonValue (string) - the carbon dioxide equivalent (CO₂e) value (kilograms)
TrackPower--tooltip-energy-carbon-used-in-preview-kilowatthour = { $value } kWh ({ $carbonValue } kg CO₂e)
.label = Energy used in the current selection

# This is used in the tooltip when the energy used in the current preview
# selection uses the watt-hour unit.
# Variables:
Expand Down
10 changes: 9 additions & 1 deletion src/components/tooltip/TrackPower.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,18 @@ class TooltipTrackPowerImpl extends React.PureComponent<Props> {

_formatPowerValue(
power: number,
l10nIdKiloUnit,
l10nIdUnit,
l10nIdMilliUnit,
l10nIdMicroUnit
): Localized {
let value, l10nId, carbonValue;
const carbon = this._computeCO2eFromPower(power);
if (power > 1) {
if (power > 1000) {
value = formatNumber(power / 1000, 3);
carbonValue = formatNumber(carbon / 1000, 2);
l10nId = l10nIdKiloUnit;
} else if (power > 1) {
value = formatNumber(power, 3);
carbonValue = formatNumber(carbon, 3);
l10nId = l10nIdUnit;
Expand Down Expand Up @@ -153,19 +158,22 @@ class TooltipTrackPowerImpl extends React.PureComponent<Props> {
<TooltipDetails>
{this._formatPowerValue(
power,
'TrackPower--tooltip-power-kilowatt',
'TrackPower--tooltip-power-watt',
'TrackPower--tooltip-power-milliwatt'
)}
{previewSelection.hasSelection
? this._formatPowerValue(
this._computePowerSumForPreviewRange(previewSelection),
'TrackPower--tooltip-energy-carbon-used-in-preview-kilowatthour',
'TrackPower--tooltip-energy-carbon-used-in-preview-watthour',
'TrackPower--tooltip-energy-carbon-used-in-preview-milliwatthour',
'TrackPower--tooltip-energy-carbon-used-in-preview-microwatthour'
)
: null}
{this._formatPowerValue(
this._computePowerSumForCommittedRange(committedRange),
'TrackPower--tooltip-energy-carbon-used-in-range-kilowatthour',
'TrackPower--tooltip-energy-carbon-used-in-range-watthour',
'TrackPower--tooltip-energy-carbon-used-in-range-milliwatthour',
'TrackPower--tooltip-energy-carbon-used-in-range-microwatthour'
Expand Down