MDK Logo

LineChartCard

Composable line-chart card with title, timeline range selector, legend (basic or detailed), error boundary, and an optional min/max/avg footer. Accepts eithe…

Composable line-chart card with title, timeline range selector, legend (basic or detailed), error boundary, and an optional min/max/avg footer.

Accepts either pre-shaped data or rawData + a dataAdapter callback so upstream domain components can keep their data wrangling local.

import { LineChartCard } from "@tetherto/mdk-react-devkit";
PropStatusTypeDefaultDescription
dataOptionalLineChartCardDataPre-adapted chart data (use this OR rawData+dataAdapter)
rawDataOptionalunknownRaw data to be transformed by dataAdapter
dataAdapterOptional(data: unknown) => LineChartCardDataAdapter to transform rawData into LineChartCardData
timelineOptionsOptionalTimelineOption[]Timeline range selector options
timelineOptionalstringControlled timeline value
defaultTimelineOptionalstringDefault timeline when uncontrolled
onTimelineChangeOptional(timeline: string) => voidCallback when timeline changes
titleOptionalstringChart title
detailLegendsOptionalbooleanShow detail legends with current values
isLoadingOptionalbooleanLoading state
shouldResetZoomOptionalbooleanWhether to reset zoom on timeline change (default: true)
chartPropsOptionalPartial<LightWeightLineChartProps>Pass-through props to the core LineChart
chartRefOptionalReact.MutableRefObject<IChartApi | null>Ref to the lightweight-charts IChartApi
minHeightOptionalstring | number
classNameOptionalstringCustom class name
headerActionOptionalReact.ReactNodeOptional action rendered on the right of the card header (e.g. an expand toggle). Passed straight through to `ChartContainer`. Additive - omit it and the card header is unchanged.
titleExtraOptionalReact.ReactNodeOptional node rendered next to the title (e.g. an info tooltip). Passed straight through to `ChartContainer`. Additive.

Usage

Composable line-chart card with title, timeline range selector, legend (basic or detailed), error boundary, and an optional min/max/avg footer.

Accepts either pre-shaped data or rawData + a dataAdapter callback so upstream domain components can keep their data wrangling local.

Data contracts

LineChartCardData exposes datasets, minMaxAvg, highlightedValue, footerStats, yTicksFormatter, and priceFormatter. See types.ts in the same directory for the full shape.

Notes

  • Wrapped in withErrorBoundary — chart-level crashes won't blow up the page.
  • For mining-domain charts, pair <LineChartCard> with adapter chart hooks (useHashrateChartData, useSiteConsumptionChartData) — the hooks return the ChartCardData payload pre-shaped.

Example

/** * Runnable example for LineChartCard. */import { LineChartCard, type LineChartCardData } from '@tetherto/mdk-react-devkit'const NOW = Date.now()const MS_PER_MIN = 60 * 1000const points = Array.from({ length: 90 }, (_, i) => ({  x: Math.floor((NOW - (90 - i) * MS_PER_MIN) / 1000),  y: 50 + Math.sin(i / 8) * 6 + Math.random() * 1.2,}))const chartData: LineChartCardData = {  datasets: [    {      label: 'Pool A',      borderColor: '#4f9ef5',      data: points,    },  ],  minMaxAvg: { min: '44', max: '58', avg: '51' },  highlightedValue: { value: 52.3, unit: 'TH/s' },}const timelineOptions = [  { label: '5m', value: '5m' },  { label: '1h', value: '1h' },  { label: '1d', value: '1D' },]export const LineChartCardExample = () => {  return (    <LineChartCard      title="Hashrate"      data={chartData}      timelineOptions={timelineOptions}      defaultTimeline="5m"      minHeight={320}    />  )}