chartTooltipIcons
A Charts block/component from shadcn/ui — clean-room reimplemented for Domphy (see methodology). Call chartTooltipIcons() with no arguments for a working demo, or edit the code below live.
Implementation notes
Full port. Header hidden; each series entry in ACTIVITY_SERIES_CONFIG carries an original inline-SVG iconMarkup string (an abstract footprint glyph for running, a wave glyph for swimming), colored via the row's resolved series color and substituted in place of the dot indicator through the shared indicator-style switch, matching the spec's 'icon present overrides the default dot' behavior.
Status: ported · Reference: shadcn/ui original
// shadcn/ui "charts/tooltip" (icons recipe) — clean-room reimplementation.
//
// Hides the date header and replaces the usual color-dot indicator with a
// small line-icon glyph per series (a footprint-style icon for running, a
// wave-style icon for swimming), colored via the series' own theme color.
//
// Implemented purely from the block's public functional/visual spec — no
// upstream shadcn/ui source was viewed or copied. Icon artwork (footprint /
// wave glyphs) is original, drawn directly as inline SVG markup.
import type { DomphyElement } from "@domphy/core";
import {
ACTIVITY_SERIES_CONFIG,
ACTIVITY_TOOLTIP_DATA,
activityBarOption,
activityTooltipCard,
activityTooltipFormatter,
activityTooltipPlot,
formatWeekdayShort,
type ActivityDayPoint,
type ActivitySeriesEntry,
} from "./chart-tooltip-shared.js";
export interface ChartTooltipIconsProps {
data?: ActivityDayPoint[];
series?: ActivitySeriesEntry[];
showCursor?: boolean;
defaultOpenIndex?: number | null;
title?: string;
description?: string;
}
/**
* shadcn/ui "charts/tooltip" icons recipe — per-series icon glyph instead of
* a color dot, no date header. Call with no arguments for a working demo.
*/
function chartTooltipIcons(props: ChartTooltipIconsProps = {}): DomphyElement<"div"> {
const {
data = ACTIVITY_TOOLTIP_DATA,
series = ACTIVITY_SERIES_CONFIG,
showCursor = false,
defaultOpenIndex = 1,
title = "Bar Chart - Tooltip Icons",
description = "Series represented by icon glyphs instead of dots",
} = props;
const categories = data.map((point) => formatWeekdayShort(point.date));
const formatter = activityTooltipFormatter(data, series, {
indicator: "icon",
showLabel: false,
});
const option = activityBarOption({ data, categories, series, showCursor, formatter });
return activityTooltipCard({
title,
description,
plot: activityTooltipPlot({ option, categories, defaultOpenIndex }),
});
}
export { chartTooltipIcons };