MDK Logo

ChartWrapper

ChartWrapper - Wrapper component for charts with loading and empty states Handles three states: - Loading: Shows skeleton loader - No data: Shows empty state…

ChartWrapper - Wrapper component for charts with loading and empty states

Handles three states: - Loading: Shows skeleton loader - No data: Shows empty state placeholder - Has data: Shows chart content

import { ChartWrapper } from "@tetherto/mdk-react-devkit";
PropStatusTypeDefaultDescription
childrenOptionalReact.ReactNodeChart content to render
dataOptionalunknown[] | Record<string, unknown> | undefinedChart data object (for LineChart with datasets)
datasetOptionalunknown[] | Record<string, unknown> | undefinedChart dataset (for BarChart with direct dataset)
isLoadingOptionalboolean | undefinedfalseLoading state
customLoaderOptionalReact.ReactNodeCustom loader component to show when loading (overrides default spinner)
showNoDataPlaceholderOptionalboolean | undefinedtrueWhether to show "no data" placeholder when data is empty
customNoDataMessageOptionalReact.ReactNodeCustom message or component to show when no data
minHeightOptionalnumber | undefinedMinimum height for the container (in pixels)
loadingMinHeightOptionalnumber | undefinedMinimum height for the loading skeleton (in pixels) Falls back to minHeight if not provided
classNameOptionalstring | undefinedCustom className for the container

Usage

Wrapper that handles three states for a chart's content area:

  • Loading — shows a Loader skeleton (or custom node).
  • No data — shows an EmptyState placeholder.
  • Has data — shows the chart children.

Example

/** * Runnable example for ChartWrapper. * * The wrapper handles three states (loading skeleton, no-data placeholder, * has-data) so individual chart components don't need to repeat the logic. */import { ChartWrapper, LineChart } from '@tetherto/mdk-react-devkit'const chartData = {  labels: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00'],  datasets: [    {      label: 'Hashrate (TH/s)',      data: [102, 104, 103, 99, 101, 105],    },  ],}export const ChartWrapperExample = () => {  return (    <ChartWrapper data={chartData} isLoading={false} minHeight={300}>      <LineChart data={chartData as never} />    </ChartWrapper>  )}