Coral Compat
APIs exported from @octopus-energy/measurements/compat
getCardProps
Maps MeasurementsOverview plus preferences into props for
<EnergyOverviewCard>.
import { getCardProps } from "@octopus-energy/measurements/compat";
const cardProps = getCardProps({
overview: electricityOverview,
utility: "electricity",
preferences,
preferencesActions,
});getCardPropsProp
Type
Input
GetCardPropsInputProp
Type
Output
CardPropsProp
Type
getTimeframeProps
Maps Timeframe and TimeframeActions into props for Coral's timeframe
controls.
import { getTimeframeProps } from "@octopus-energy/measurements/compat";
const tfProps = getTimeframeProps({ timeframe, timeframeActions });getTimeframePropsProp
Type
The returned object contains three prop groups:
tfProps.timeframeControls: for<EnergyOverviewTimeframeControls>tfProps.toggleButton: for<EnergyOverviewTimeframeToggleButton>tfProps.navigation: for<EnergyOverviewTimeframeNavigation>
Input
GetTimeframePropsInputProp
Type
Output
TimeframePropsProp
Type
EnergySummary compat helpers
These helpers are a clear temporary bridge between future-facing summary
role-helper outputs and Coral's current EnergySummary prop names. They do not
select metrics; call the summary role helpers first, then adapt the role output
at the Coral render point.
import {
getSummaryChartBarProps,
getSummaryChartLabelProps,
getSummaryIndicatorsProps,
} from "@octopus-energy/measurements/compat";
import {
getSummaryChartBars,
getSummaryChartLabels,
getSummaryIndicators,
} from "@octopus-energy/measurements/summary";
const indicators = getSummaryIndicators(summary);
const chartBars = getSummaryChartBars(summary);
const chartLabels = getSummaryChartLabels(summary);
const indicatorProps = getSummaryIndicatorsProps(indicators);
const weekBeforeBars = getSummaryChartBarProps(chartBars.weekBefore);
const weekBeforeLabel = getSummaryChartLabelProps(chartLabels.weekBefore);getSummaryChartBarPropsProp
Type
getSummaryChartBarProps
Maps SummaryChartBar[] to the current props for <EnergySummaryChart>.
Current Coral expects both period totals for scaling. Summary chart bars already
carry a single value plus a compatible-bucket maxValue, so the adapter
passes maxValue as the opposite period total.
{
getSummaryChartBarProps(chartBars.weekBefore).map(({ key, ...chart }) => (
<EnergySummaryChart key={key} {...chart} />
));
}SummaryChartBarProps<TFilters>Prop
Type
getSummaryChartLabelProps
Maps a SummaryChartLabel to the current props for <EnergySummaryChartLabel>.
The adapter maps the summary label string to Coral's current value prop.
<EnergySummaryChartLabel {...getSummaryChartLabelProps(chartLabels.weekBefore)} />SummaryChartLabelPropsProp
Type
getSummaryIndicatorsProps
Maps SummaryIndicator[] to the current props for <EnergySummaryIndicator>
and app-owned indicator copy. Current Coral accepts only "up" | "down" for the
indicator icon direction, so delta.trend === "stable" maps to the current down
icon direction while the semantic trend remains available at
indicator.delta.trend.
{
getSummaryIndicatorsProps(indicators).map((indicator) => (
<EnergySummaryIndicators key={indicator.key}>
<EnergySummaryIndicator direction={indicator.direction} />
<Typography textStyle="body2">{/* Render localized text from indicator.delta. */}</Typography>
</EnergySummaryIndicators>
));
}SummaryIndicatorProps<TFilters>Prop
Type
getDateRangeDisplay
Formats the current timeframe into a human-readable date string for display in
<EnergyOverviewDateDisplay>.
import { getDateRangeDisplay } from "@octopus-energy/measurements/compat";
const display = getDateRangeDisplay(timeframe, dateLocale);getDateRangeDisplayProp
Type
Returns: string
Output formats
| Timeframe | Output |
|---|---|
| Single day | The formatted anchor date |
| Multi-day | The formatted start and end dates |
Related
- Create the Shell: parent-level timeframe control wiring
- Render Usage Charts:
card-level
getCardPropsusage - Summary API reference: producing role-helper outputs for EnergySummary
- Overview API reference:
producing the
MeasurementsOverviewinput - Timeframe: the timeframe
passed to
getTimeframeProps