Chart components
Data visualization components for mining metrics
Chart components for visualizing time-series data, metrics, and statistics. Built on Chart.js and Lightweight Charts, supporting:
- Chart types: components that render datasets (
AreaChart,BarChart,DoughnutChart,GaugeChart,LineChart) - Domain chart wrappers: opinionated chart components with preset layouts and series config (
AverageDowntimeChart,ThresholdLineChart,OperationsEnergyCostChart) - Composition elements: layout chrome, legends, stats rows, and chart utilities (
ChartContainer,ChartStatsFooter,DetailLegend, helpers)
Prerequisites
All chart type components
| Component | Description |
|---|---|
LineChart | Time-series or trend visualization |
BarChart | Vertical/horizontal bar chart for comparisons |
AreaChart | Filled line chart for volume/cumulative data |
DoughnutChart | Circular chart for part-to-whole relationships |
GaugeChart | Presentational arc gauge for normalized percentages |
AverageDowntimeChart | Stacked bar chart for curtailment and operational downtime rates |
ThresholdLineChart | Line chart with configurable horizontal threshold bands |
OperationsEnergyCostChart | Doughnut chart comparing operational and energy costs |
AreaChart
Filled area chart for cumulative or range data.
Presentational Chart.js area chart (line series with fill). Data and options follow the same Chart.js model as LineChart, without a
separate MDK data wrapper type.
Import
import { AreaChart } from '@tetherto/mdk-react-devkit/core'Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
data | Required | ChartData | none | Chart.js line chart data (datasets typically use fill: true for an area look) |
options | Optional | ChartOptions | none | Chart.js options (merged with defaults) |
tooltip | Optional | ChartTooltipConfig | none | Custom HTML tooltip config; when set, replaces the default Chart.js tooltip |
height | Optional | number | 300 | Chart height in pixels |
className | Optional | string | none | Root class name from the host app |
Basic usage
const data = {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
datasets: [
{
label: 'Revenue',
data: [100, 120, 115, 134, 168],
fill: true,
backgroundColor: 'rgba(114, 245, 158, 0.2)',
borderColor: '#72F59E',
},
],
}
<AreaChart data={data} />BarChart
Bar/column chart with gradient fills, stacking, and data labels. Built on Chart.js.
The BarChart component renders Chart.js bar or column series. It manages:
- Data (
data): labels and datasets passed to Chart.js. - Chart options (
options): merged with MDK defaults. - Formatting (
formatYLabel,formatDataLabel,tooltip): axis labels, data labels, and HTML tooltips. - Presentation (
isStacked,isHorizontal,showLegend,legendPosition,legendAlign,showDataLabels): layout and legend. - Size (
height): chart height in pixels.
Import
import { BarChart } from '@tetherto/mdk-react-devkit/core'Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
data | Required | ChartData | none | Chart.js data object |
options | Optional | ChartOptions | none | Chart.js options (merged with defaults) |
formatYLabel | Optional | function | none | Format Y-axis tick labels |
formatDataLabel | Optional | function | none | Format data label values |
tooltip | Optional | ChartTooltipConfig | none | Custom HTML tooltip config |
isStacked | Optional | boolean | false | Stack bars on top of each other |
isHorizontal | Optional | boolean | false | Render bars horizontally |
showLegend | Optional | boolean | true | Show Chart.js legend |
legendPosition | Optional | 'top' | 'right' | 'bottom' | 'left' | 'top' | Legend position |
legendAlign | Optional | 'start' | 'center' | 'end' | 'start' | Legend alignment |
showDataLabels | Optional | boolean | false | Show values above bars |
height | Optional | number | 300 | Chart height in pixels |
Basic usage
const data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr'],
datasets: [
{
label: 'Hashrate (TH/s)',
data: [120, 150, 180, 200],
backgroundColor: '#72F59E',
},
],
}
<BarChart data={data} height={300} />Data from hooks
Hand-built Chart.js data (above) is valid. When app hooks return { labels, series } declarative input, convert with
buildBarChartData in chart utilities,
optionally merge per-series datalabels, then pass the result to data.
Stacked bar chart
const data = {
labels: ['Site A', 'Site B', 'Site C'],
datasets: [
{ label: 'Online', data: [100, 80, 120], backgroundColor: '#72F59E' },
{ label: 'Offline', data: [10, 20, 5], backgroundColor: '#FF6B6B' },
],
}
<BarChart data={data} isStacked />Horizontal bar chart
<BarChart
data={data}
isHorizontal
formatYLabel={(value) => `${value} TH/s`}
/>With data labels
<BarChart
data={data}
showDataLabels
formatDataLabel={(value) => `${value.toFixed(1)}%`}
/>DoughnutChart
Doughnut/pie chart for proportional data.
Import
import { DoughnutChart } from '@tetherto/mdk-react-devkit/core'Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
data | Required | DoughnutChartDataset[] | none | Array of { label, value, color? } slices (see data shape) |
unit | Optional | string | '' | Unit suffix shown in the default tooltip |
options | Optional | ChartOptions | none | Chart.js doughnut options (merged with defaults) |
cutout | Optional | string | '75%' | Inner radius cutout (doughnut ring thickness) |
borderWidth | Optional | number | 4 | Border width between segments |
height | Optional | number | 260 | Chart height in pixels |
legendPosition | Optional | string | 'top' | Where to place the custom legend relative to the chart |
tooltip | Optional | ChartTooltipConfig | none | Custom HTML tooltip; when set, replaces the default doughnut tooltip |
className | Optional | string | none | Root class name from the host app |
Data shape for doughnut charts
Pass data as an array of { label, value, color? }. The chart maps this into Chart.js internally
(labels, single dataset, segment colors). Omit color to use the default palette rotation.
Basic usage
const data = [
{ label: 'Online', value: 85, color: '#72F59E' },
{ label: 'Offline', value: 10, color: '#FF6B6B' },
{ label: 'Maintenance', value: 5, color: '#FFD700' },
]
<DoughnutChart data={data} />GaugeChart
Speedometer-style presentational arc gauge for displaying a single normalized value, providing:
- Percent (
percent): fill level from0to1(values outside that range are clamped). - Arc appearance (
colors,arcWidth,nrOfLevels): segment colors, relative thickness, and segment count. - Center label (
hideText): percentage text in the center of the gauge (hidden whenhideTextistrue). - Accessibility (
id): stable id wired into SVG labels (defaults tomdk-gauge-chart). - Layout (
height,maxWidth,className): container height, max width, and host root class.
SVG speedometer-style gauge driven by a 0–1 percent value.
The GaugeChart is SVG-based; strokes and labels may paint past the host element’s layout bounds. For a hard edge, wrap the gauge in an element
with overflow: hidden, or add vertical spacing. ChartContainer does not set overflow clipping on the
chart slot—it is for title, loading/empty, and footer chrome like other charts (see Composition); it may add spacing that makes
overlap less visible, but it is not a substitute for clipping when you need it.
Import
import { GaugeChart } from '@tetherto/mdk-react-devkit/core'The gauge is driven by a normalized percent in the range 0–1 (for example 0.75 is 75%). It is not a value / max API, and it
does not accept label or unit props (see ChartContainer for layout notes).
Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
percent | Required | number | none | Fill level from 0 to 1 (clamped) |
colors | Optional | string[] | green → soft green → red (theme) | Arc segment colors as HEX strings |
arcWidth | Optional | number | 0.2 | Arc thickness as a fraction of the gauge radius (0–1) |
nrOfLevels | Optional | number | 3 | Number of colored segments on the arc |
hideText | Optional | boolean | false | Hide the percentage text in the center |
id | Optional | string | 'mdk-gauge-chart' | Stable id for SVG accessibility labels |
height | Optional | number | string | 200 | Container height (pixels or CSS length, e.g. '50%') |
maxWidth | Optional | number | 500 | Maximum width in pixels |
className | Optional | string | none | Root class name from the host app |
Basic usage
<GaugeChart percent={0.75} />In a chart card (same shell as other charts)
ChartContainer adds title, loading, and empty chrome; it does not apply overflow: hidden to the chart body.
When you still see bleed next to siblings or footers, wrap GaugeChart in an extra element with overflow: hidden.
import { ChartContainer, GaugeChart } from '@tetherto/mdk-react-devkit/core'
<ChartContainer title="Utilization" loading={false} empty={false}>
<div style={{ overflow: 'hidden' }}>
<GaugeChart percent={0.75} />
</div>
</ChartContainer>Custom colors and arc
<GaugeChart
percent={0.6}
colors={['#72F59E', '#FFD700', '#FF6B6B']}
arcWidth={0.25}
nrOfLevels={3}
hideText={false}
height={220}
/>LineChart
Time-series line chart built on Lightweight Charts for high-performance rendering.
The LineChart component renders time-series lines. It manages:
- Series data (
data):LineChartDatawith millisecondxvalues (see data shape). - Context (
timeline,unit): timeline identifier and unit label for tooltips. - Formatting (
yTicksFormatter,priceFormatter,customLabel): tick and tooltip text. - Presentation (
backgroundColor,beginAtZero,showPointMarkers,showDateInTooltip,uniformDistribution): axis and marker behavior. - Size (
height): chart height in pixels.
Import
import { LineChart } from '@tetherto/mdk-react-devkit/core'Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
data | Required | LineChartData | none | Object with a datasets array (see data shape) |
timeline | Optional | string | none | Timeline identifier |
yTicksFormatter | Optional | function | none | Format Y-axis ticks |
priceFormatter | Optional | function | none | Format tooltip values |
customLabel | Optional | string | none | Custom tooltip label |
unit | Optional | string | '' | Unit label for values |
backgroundColor | Optional | string | none | Chart background color |
beginAtZero | Optional | boolean | false | Start Y-axis at zero |
showPointMarkers | Optional | boolean | false | Show data point markers |
showDateInTooltip | Optional | boolean | false | Show date in tooltip |
uniformDistribution | Optional | boolean | false | Uniform time distribution |
height | Optional | number | 240 | Chart height in pixels |
Data shape for line charts
LineChartData is { datasets: LineDataset[] }. Each LineDataset has label, borderColor, optional visible / borderWidth / extraTooltipData,
and data: { x, y }[] where x is a time value in milliseconds (for example from Date.prototype.valueOf()) and y is the series value
(number, or null / undefined for gaps).
Basic usage
const data = {
datasets: [
{
label: 'Hashrate',
borderColor: '#72F59E',
data: [
{ x: 1704067200000, y: 150 },
{ x: 1704153600000, y: 155 },
{ x: 1704240000000, y: 160 },
],
},
],
}
<LineChart data={data} height={300} unit="TH/s" />Multiple lines
const hashrateData = [
{ x: 1704067200000, y: 150 },
{ x: 1704153600000, y: 155 },
]
const targetData = [
{ x: 1704067200000, y: 140 },
{ x: 1704153600000, y: 145 },
]
const data = {
datasets: [
{
label: 'Hashrate',
borderColor: '#72F59E',
data: hashrateData,
},
{
label: 'Target',
borderColor: '#FFD700',
data: targetData,
},
],
}
<LineChart data={data} showPointMarkers beginAtZero />AverageDowntimeChart
Opinionated stacked bar chart wrapping ChartContainer and BarChart with domain-specific downtime series and a rate formatter.
Stacked bar chart showing monthly average downtime broken into Curtailment and Op. Issues series. Wraps ChartContainer and BarChart. It manages:
- Data (
data): period labels and per-series rate arrays (values are fractions 0–1). - Formatting (
yTicksFormatter): formats Y-axis ticks, tooltips, and optional bar data labels. - Presentation (
showDataLabels,title,unit): bar data labels and header text. - Layout (
height,barWidth): chart height and bar width in pixels. - State (
isLoading,emptyMessage): loading overlay and empty-state copy.
Import
import { AverageDowntimeChart } from '@tetherto/mdk-react-devkit/core'Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
data | Optional | AverageDowntimeChartData | none | Period labels and downtime rate arrays (see data shape) |
yTicksFormatter | Optional | function | defaultAverageDowntimeRateFormatter | Formats Y-axis ticks, tooltips, and data labels; input values are 0–1 rates |
showDataLabels | Optional | boolean | false | Show formatted rate values above each bar segment |
title | Optional | string | 'Monthly Average Downtime' | Header title |
unit | Optional | string | '%' | Unit label shown beneath the title |
height | Optional | number | 280 | Chart height in pixels |
barWidth | Optional | number | 38 | Bar width in pixels |
isLoading | Optional | boolean | false | When true, shows a loading overlay |
emptyMessage | Optional | string | 'No data available' | Copy shown in the empty state |
className | Optional | string | none | Root class name from the host app |
Data shape for AverageDowntimeChart
Pass data as an AverageDowntimeChartData object:
| Field | Type | Description |
|---|---|---|
labels | string[] | Period labels (e.g. month names) |
curtailment | number[] | Curtailment downtime rates (0–1) per period |
operationalIssues | number[] | Operational issue downtime rates (0–1) per period |
Both series arrays are optional; absent series are omitted from the chart.
Basic usage
import { AverageDowntimeChart } from '@tetherto/mdk-react-devkit/core'
<AverageDowntimeChart
data={{
labels: ['Jan', 'Feb', 'Mar'],
curtailment: [0.02, 0.01, 0.03],
operationalIssues: [0.05, 0.04, 0.06],
}}
/>Custom formatter
yTicksFormatter receives raw 0–1 rate values and must return a display string. The default (defaultAverageDowntimeRateFormatter) multiplies by 100 and appends %:
import {
AverageDowntimeChart,
defaultAverageDowntimeRateFormatter,
} from '@tetherto/mdk-react-devkit/core'
// Override: show one decimal place
<AverageDowntimeChart
data={data}
yTicksFormatter={(rate) => `${(rate * 100).toFixed(1)}%`}
showDataLabels
/>Exported helpers
| Export | Role |
|---|---|
buildAverageDowntimeBarChartData | Converts AverageDowntimeChartData into Chart.js data |
buildAverageDowntimeTooltip | Builds the HTML tooltip config for the stacked bars |
defaultAverageDowntimeRateFormatter | Default Y-axis / label formatter (rate × 100, % suffix) |
hasAverageDowntimeData | Returns true when data has at least one non-empty series |
ThresholdLineChart
Time-series line chart wrapping ChartContainer and LineChart, with support for optional horizontal threshold reference lines and interactive legend toggles.
Time-series line chart with optional horizontal threshold bands. Wraps ChartContainer and LineChart. It manages:
- Data (
data): one or more line series plus optional threshold lines. - Formatting (
yTicksFormatter): formats Y-axis ticks. - Presentation (
title,unit,isTall,isLegendVisible): header, height variant, and legend toggle. - Layout (
height): explicit chart height in pixels (overridesisTall). - State (
emptyMessage): empty-state copy.
Import
import { ThresholdLineChart } from '@tetherto/mdk-react-devkit/core'Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
data | Optional | ThresholdLineChartData | none | Series and optional thresholds (see data shape) |
yTicksFormatter | Optional | function | unit-aware default | Formats Y-axis tick labels; defaults to "${value} ${unit}" when unit is set, otherwise String(value) |
title | Optional | string | none | Header title; rendered as "${title} (${unit})" when both are set |
unit | Optional | string | none | Unit appended to the title and used by the default tick formatter |
isTall | Optional | boolean | false | When true, uses a taller default height of 360px instead of 280px |
isLegendVisible | Optional | boolean | true | Show the interactive legend with dataset visibility toggles |
height | Optional | number | 280 (360 when isTall) | Chart height in pixels; explicit value overrides isTall |
emptyMessage | Optional | string | 'No data available' | Copy shown in the empty state |
className | Optional | string | none | Root class name from the host app |
Data shape for ThresholdLineChart
ThresholdLineChartData holds series and optional threshold lines:
| Field | Type | Description |
|---|---|---|
series | ThresholdLineChartSeries[] | Line series to render |
thresholds | ThresholdLineChartThreshold[] | Optional horizontal reference lines |
Each ThresholdLineChartSeries:
| Field | Type | Description |
|---|---|---|
label | string | Series label shown in the legend |
points | ThresholdLineChartPoint[] | Data points ({ timestamp: string | number, value: number }) |
color | string | Optional line color |
fill | boolean | Optional area fill below the line |
Each ThresholdLineChartThreshold:
| Field | Type | Description |
|---|---|---|
label | string | Label shown in the legend |
value | number | Y-axis value at which the horizontal line is drawn |
color | string | Optional line color |
Basic usage
import { ThresholdLineChart } from '@tetherto/mdk-react-devkit/core'
<ThresholdLineChart
title="Power Consumption"
unit="MW"
data={{
series: [
{
label: 'Actual',
color: '#72F59E',
points: [
{ timestamp: '2025-01-01', value: 32 },
{ timestamp: '2025-01-02', value: 35 },
{ timestamp: '2025-01-03', value: 29 },
],
},
],
thresholds: [
{ label: 'Capacity limit', value: 38, color: '#FF6B6B' },
],
}}
/>Tall variant
<ThresholdLineChart
title="Hashrate"
unit="TH/s"
isTall
data={data}
/>Exported helpers
| Export | Role |
|---|---|
toThresholdLineChartData | Converts ThresholdLineChartData into LineChartData for the underlying LineChart |
hasNonZeroData | Returns true when data contains at least one series with a non-zero value |
OperationsEnergyCostChart
Doughnut chart wrapping ChartContainer and DoughnutChart for operations vs energy cost breakdown in USD per MWh.
Doughnut chart comparing operational costs against energy costs in USD per MWh. Wraps ChartContainer and DoughnutChart. It manages:
- Data (
data): operational and energy cost values in USD. - Presentation (
title,unit): header text and unit label. - Layout (
height): chart height in pixels. - State (
isLoading,emptyMessage): loading overlay and empty-state copy.
Import
import { OperationsEnergyCostChart } from '@tetherto/mdk-react-devkit/core'Props
| Prop | Status | Type | Default | Description |
|---|---|---|---|---|
data | Optional | OperationsEnergyCostChartData | none | Cost values in USD (see data shape) |
title | Optional | string | 'Operations vs Energy Cost' | Header title |
unit | Optional | string | '$/MWh' | Unit label shown beneath the title |
height | Optional | number | 200 | Chart height in pixels |
isLoading | Optional | boolean | false | When true, shows a loading overlay |
emptyMessage | Optional | string | 'No data available' | Copy shown in the empty state |
className | Optional | string | none | Root class name from the host app |
Data shape for OperationsEnergyCostChart
OperationsEnergyCostChartData has two optional numeric fields:
| Field | Type | Description |
|---|---|---|
operationalCostsUSD | number | Operational costs in USD |
energyCostsUSD | number | Energy costs in USD |
Both fields are optional. Slices with a zero or absent value are omitted from the doughnut.
Basic usage
import { OperationsEnergyCostChart } from '@tetherto/mdk-react-devkit/core'
<OperationsEnergyCostChart
data={{
operationalCostsUSD: 1200,
energyCostsUSD: 4800,
}}
/>Exported helpers
| Export | Role |
|---|---|
buildOperationsEnergyCostSlices | Converts OperationsEnergyCostChartData into DoughnutChartDataset[] slices, omitting zero-value entries |
buildOperationsEnergyCostTooltip | Builds the HTML tooltip config with two-decimal formatting |
hasOperationsEnergyCostData | Returns true when at least one cost field is a positive number |