MDK Logo

EnergyBalanceCostMetrics

Grid of stat cards summarising energy cost metrics for the selected period.

Grid of stat cards summarising energy cost metrics for the selected period.

import { EnergyBalanceCostMetrics } from "@tetherto/mdk-react-devkit";
PropStatusTypeDefaultDescription
metricsRequiredEnergyCostMetrics

Usage

Components for the Energy Balance financial reporting section.

ComponentDescription
EnergyBalanceTop-level energy balance dashboard with tabbed revenue and cost views.
EnergyBalanceCostChartsLayout container for the energy cost tab: revenue-vs-cost bar chart and power line chart.
EnergyBalanceCostMetricsGrid of stat cards summarising cost metrics for the selected period.
EnergyBalanceRevenueChartsMosaic layout of revenue, downtime, and power charts for the revenue tab.
EnergyBalanceRevenueMetricsGrid of stat cards summarising revenue metrics for the selected period.

EnergyBalance Props

PropTypeDescription
viewModelEnergyBalanceViewModelAll display state: chart inputs, metrics, active tab, display modes, loading/error flags. Returned directly by useEnergyBalanceViewModel.
onTabChange(tab: EnergyBalanceTab) => voidCalled when the user switches between Revenue and Cost tabs.
onRevenueDisplayModeChange(mode: DisplayMode) => voidCalled when the user toggles USD / BTC on the revenue tab.
onCostDisplayModeChange(mode: DisplayMode) => voidCalled when the user toggles USD / BTC on the cost tab.
timeframeControlsReactNodeOptional slot for date-range controls rendered by the host app.
setCostHrefstringOptional URL for the "Set Monthly Cost" action (hidden when omitted).
isDemoModebooleanSuppresses error banners in demo/mock environments.

Typical usage with useEnergyBalanceViewModel

import { EnergyBalance, useEnergyBalanceViewModel } from '@tetherto/mdk-react-devkit'

const MyPage = ({ data, isLoading, errors, dateRange, availablePowerMW }) => {
  const { queryParams, ...componentProps } = useEnergyBalanceViewModel({
    data,
    isLoading,
    fetchErrors: errors,
    dateRange,
    availablePowerMW,
  })

  return (
    <EnergyBalance
      {...componentProps}
      timeframeControls={<MyDateRangePicker />}
      setCostHref="/settings/energy-cost"
    />
  )
}

queryParams contains the { start, end, period } values to pass to your API call. Everything else from the hook maps directly onto EnergyBalance.

Examples

import { EnergyBalanceCostCharts } from '@tetherto/mdk-react-devkit'export const EnergyBalanceCostChartsExample = () => (  <div className="mdk-example-row">    <EnergyBalanceCostCharts      costChartData={{ labels: [], datasets: [] } as never}      btcUnit="BTC"      powerChartInput={{ datasets: [], threshold: null } as never}      displayMode="USD"      barLabelFormatter={(value) => String(value)}      onDisplayModeChange={() => undefined}      showCostBarChart={true}      periodType="month"    />  </div>)
import { EnergyBalanceCostMetrics } from '@tetherto/mdk-react-devkit'export const EnergyBalanceCostMetricsExample = () => (  <div className="mdk-example-row">    <EnergyBalanceCostMetrics      metrics={{        avgPowerConsumption: 11.8,        avgEnergyCost: 38.2,        avgAllInCost: 42.5,        avgPowerAvailability: 12.5,        avgOperationsCost: 4.3,        avgEnergyRevenue: 55.0,      }}    />  </div>)
import { EnergyBalanceRevenueCharts } from '@tetherto/mdk-react-devkit'export const EnergyBalanceRevenueChartsExample = () => (  <div className="mdk-example-row">    <EnergyBalanceRevenueCharts      revenueChartData={{ labels: [], datasets: [] } as never}      averageDowntimeData={{ labels: [], curtailment: [], operationalIssues: [] }}      powerChartInput={{ datasets: [], threshold: null } as never}      displayMode="USD"      barLabelFormatter={(value) => String(value)}      onDisplayModeChange={() => undefined}      periodType="month"      revenueMetrics={{ curtailmentRate: 3.2, operationalIssuesRate: 1.5 }}    />  </div>)
import { EnergyBalanceRevenueMetrics } from '@tetherto/mdk-react-devkit'export const EnergyBalanceRevenueMetricsExample = () => (  <div className="mdk-example-row">    <EnergyBalanceRevenueMetrics metrics={{ curtailmentRate: 3.2, operationalIssuesRate: 1.5 }} />  </div>)
import { EnergyBalance } from '@tetherto/mdk-react-devkit'export const EnergyBalanceExample = () => (  <div className="mdk-example-row">    <EnergyBalance      viewModel={{        revenueMetrics: null,        costMetrics: null,        energyRevenueChartInput: { datasets: [], threshold: null } as never,        averageDowntimeData: { labels: [], curtailment: [], operationalIssues: [] },        powerChartInput: { datasets: [], threshold: null } as never,        powerChartCostInput: { datasets: [], threshold: null } as never,        energyCostChartInput: { datasets: [], btcUnit: 'BTC', threshold: null } as never,        activeTab: 'revenue',        revenueDisplayMode: 'USD',        costDisplayMode: 'USD',        revenueBarLabelFormatter: (v) => String(v),        costBarLabelFormatter: (v) => String(v),        period: 'monthly',        periodType: 'month',        hasData: false,        isLoading: false,        errors: [],        hasDateSelection: false,      }}      onTabChange={() => undefined}      onRevenueDisplayModeChange={() => undefined}      onCostDisplayModeChange={() => undefined}    />  </div>)