Files
chartkit/dist/react/Bars.d.ts
T
CatoandClaude b54b26715e feat: ShareBars otherLabel and a ColumnChart for values by period (#9)
ShareBars took {rows, caption, other} and always called the remainder
"Other", so an app that knew what its rest was ("Others, each below 5%")
could only say it in the caption. `otherLabel` names it in the legend and the
table; left out, it is still "Other".

ColumnChart draws figures by period: revenue and net income by fiscal year,
periods left to right in the order given (fiscal labels are not dates, so
nothing re-sorts them), several series side by side, a loss below the zero
line, a missing figure as no column and "—" in the table, each column
focusable with its value and a link to its source. The ranked BarChart could
not do this: it re-orders rows by size, so a year chart came out of order.

Release 0.2.0.


Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-27 08:55:08 +01:00

53 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export interface BarRow {
label: string;
/** `null` when the source gives no number: drawn as "—", never as zero. */
value: number | null;
href?: string;
/** 0–1, shown in muted mono beside the value. */
share?: number;
note?: string;
/** The source marks the value estimated. */
estimated?: boolean;
}
export interface BarChartProps {
rows: BarRow[];
unit?: string;
caption: string;
/** The label of the row to draw in the accent: "this one", among the rest. */
highlight?: string;
/** Full-scale value for proportional bars (for example 100 for percentages).
* Values above this still fit. Invalid/non-positive scales use the largest row. */
max?: number;
}
/**
* Horizontal ranked bars: label left, bar, value right. Rows are ranked —
* largest first, no number last — whatever order they arrive in; a chart
* called ranked that trusts its caller's order is sometimes not ranked.
*/
export declare function BarChart({ rows, unit, caption, highlight, max: whole }: BarChartProps): import("react").JSX.Element;
export interface ShareRow {
label: string;
/** 0–1. */
share: number;
href?: string;
}
export interface ShareBarsProps {
rows: ShareRow[];
caption: string;
/** 0–1: the rest, drawn last in the line colour and listed as `otherLabel`. */
other?: number;
/**
* What the rest IS, in the legend and the table: "Others, each below 5%".
* Left out, "Other". A bare "Other 87%" asks the reader to guess; the app
* knows what its remainder is and should say it here.
*/
otherLabel?: string;
}
/**
* One 100% stacked bar with a legend row under it. The largest segment
* carries its label inside when the segment is wide enough for it (a
* container query, so the same markup decides at every width); every
* segment is named in the legend.
*/
export declare function ShareBars({ rows, caption, other, otherLabel }: ShareBarsProps): import("react").JSX.Element;
//# sourceMappingURL=Bars.d.ts.map