chartAreaLinear
A Charts block/component from shadcn/ui — clean-room reimplemented for Domphy (see methodology). Call chartAreaLinear() with no arguments for a working demo, or edit the code below live.
Props
| Prop | Type | Description |
|---|---|---|
data | ChartAreaSinglePoint[] | — |
seriesLabel | string | — |
seriesColor | ThemeColor | — |
title | string | — |
description | string | — |
trendText | string | — |
trendDirection | ChartTrendDirection | — |
captionText | string | — |
height | number | — |
Implementation notes
Identical structure to chartAreaDefault with smooth (straight point-to-point segments). Same mount-reveal approximation caveat as chartAreaDefault. Direct-source-diff fix (2026-07-05): Same tooltip hideLabel gap and missing horizontal gridlines as chartAreaStep. Fixed.
Status: partial · Reference: shadcn/ui original
// shadcn/ui "chart-area" (linear recipe) — clean-room reimplementation.
//
// Structurally identical to the default recipe, but with straight
// (unsmoothed) segments connecting each data point instead of a smoothed
// curve, giving a more angular silhouette.
//
// Implemented purely from the block's public functional/visual spec — no
// upstream shadcn/ui source was viewed or copied.
import type { ChartOption } from "@domphy/chart";
import type { DomphyElement } from "@domphy/core";
import type { ThemeColor } from "@domphy/theme";
import {
CHART_AREA_MONTHLY_DATA,
CHART_AREA_X_AXIS_BARE,
CHART_AREA_Y_AXIS_HIDDEN,
type ChartAreaSinglePoint,
type ChartTrendDirection,
chartAreaFrame,
chartAreaGradientFill,
chartAreaSeriesColor,
chartAxisTooltipFormatter,
chartCardShell,
chartTrendFooter,
} from "./chart-area-shared.js";
export interface ChartAreaLinearProps {
data?: ChartAreaSinglePoint[];
seriesLabel?: string;
seriesColor?: ThemeColor;
title?: string;
description?: string;
trendText?: string;
trendDirection?: ChartTrendDirection;
captionText?: string;
height?: number;
}
/**
* shadcn/ui "chart-area" linear recipe — a single-series area chart with
* straight point-to-point segments. Call with no arguments for a working
* demo.
*/
function chartAreaLinear(
props: ChartAreaLinearProps = {},
): DomphyElement<"div"> {
const {
data = CHART_AREA_MONTHLY_DATA,
seriesLabel = "Visitors",
seriesColor = "primary",
title = "Area Chart - Linear",
description = "Showing total visitors for the last 6 months",
trendText = "Trending up by 5.2% this month",
trendDirection = "up",
captionText = `${data[0]?.month ?? ""} - ${data[data.length - 1]?.month ?? ""} 2026`,
height = 64,
} = props;
const categories = data.map((point) => point.month);
const ramp = chartAreaSeriesColor(0);
const option: ChartOption = {
tooltip: {
trigger: "axis",
axisPointer: { type: "none" },
// Upstream: `<ChartTooltipContent indicator="dot" hideLabel />` with no
// value formatter — bare number, no " visitors" unit.
formatter: chartAxisTooltipFormatter(categories, undefined, true),
},
xAxis: { ...CHART_AREA_X_AXIS_BARE, data: categories },
yAxis: CHART_AREA_Y_AXIS_HIDDEN,
grid: { left: 8, right: 8, top: 12, bottom: 32, containLabel: false },
series: [
{
type: "line",
name: seriesLabel,
smooth: false,
showSymbol: false,
color: seriesColor,
lineStyle: { width: 2, opacity: ramp.strokeOpacity },
areaStyle: {
color: chartAreaGradientFill("primary", 0.4, 0.4, ramp.tone),
opacity: 1,
},
data: data.map((point) => point.value),
},
],
};
return chartCardShell({
title,
description,
content: { div: [chartAreaFrame(option, height)] },
footer: chartTrendFooter({
trendText,
direction: trendDirection,
captionText,
}),
});
}
export { chartAreaLinear };