Skip to Content
🎉 Coral x Panda has been released 🎉 Read the Migration Guide

useEnergySummary

This hook is used to transform the raw measurements data into useful statistics that can be displayed inside the EnergySummary component.

Basic Usage

import { useEnergySummary } from '@krakentech/coral-charts'; const { percentageDifference, energyTypeLabel, electricity, gas, weekBeforeCostTotalFormatted, lastWeekCostTotalFormatted, } = useEnergySummary({ data, energyType: 'dual', loading: false, error: false, currency: 'GBP', locale: 'en', });

The returned values can then be used to display the relevant statistics inside your component. Please see the EnergySummary component for a full example.

Full API

Arguments

NameDescriptiontypeDefault valueRequired
dataThe initial data provided by the consumer from the GraphQL queryEnergySummaryDataTypeundefinedtrue
energyTypeThe energy type(s) this chart should displayelectricity, gas, dualundefinedtrue
loadingThe loading state from the GraphQL querybooleanundefinedtrue
errorThe error state from the GraphQL queryunknownundefinedtrue
currencyThe local 3-digit currency codeGBP, USD, EUR, JPY, AUD, NZD, stringundefinedtrue
localeThe local 2-digit locale codeen, us, fr, de, es, it, ja, au, nzundefinedtrue

Return

NameDescriptiontype
percentageDifferenceThe total percentage difference between the energy consumed in the week before, compared to last weeknumber
kwhDifferenceThe total kWh difference between the energy consumed in the week before, compared to last weeknumber
energyTypeLabelThe human-readable label that will be displayed when talking about which energy type they are viewing'gas', 'electricity', 'energy'
weekBeforeCostTotalFormattedThe total week before cost formatted based on your currency and localestring
lastWeekCostTotalFormattedLast week’s total cost formatted based on your currency and localestring
[energy type].weekBeforeData.costValueThe cost value of the week beforenumber
[energy type].weekBeforeData.consumptionValueThe consumption value of the week beforenumber
[energy type].weekBeforeData.isCostAvailableWhether the cost data is available for the week beforeboolean
[energy type].weekBeforeData.costValueFormattedThe formatted cost value of the week before based on your currency and localestring
[energy type].weekBeforeData.consumptionValueFormattedThe formatted consumption value of the week before based on your localestring
[energy type].weekBeforeData.costDifferenceFormattedThe formatted cost difference between the week before and last week based on your currency and localestring
[energy type].lastWeekDataThe same structure as weekBeforeData, but for last weekTimePeriodDataType
[energy type].costDifferenceFormattedThe formatted cost difference between the week before and last week based on your currency and localestring
Last updated on