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) - 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 |
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 />