@ruckc/truss-chart 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ import type { Series } from './types.js';
2
+ type $$ComponentProps = {
3
+ categories: string[];
4
+ /** Up to 8 series (fixed-order palette). Negative values are allowed everywhere, including stacked bars. */
5
+ series: Series[];
6
+ title?: string;
7
+ subtitle?: string;
8
+ /** Plot height in px (horizontal charts grow to fit their categories). */
9
+ height?: number;
10
+ /** `true` stacks values (positives up/right of zero, negatives down/left); `'percent'` normalises each category to 100%. */
11
+ stacked?: boolean | 'percent';
12
+ /** Bars run left→right with categories down the side — better for long labels and many categories. */
13
+ horizontal?: boolean;
14
+ /** Label the end of each bar (the stack total when stacked). */
15
+ showValues?: boolean;
16
+ yFormat?: (n: number) => string;
17
+ };
18
+ declare const BarChart: import("svelte").Component<$$ComponentProps, {}, "">;
19
+ type BarChart = ReturnType<typeof BarChart>;
20
+ export default BarChart;
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { LegendItem } from './types.js';
3
+ type $$ComponentProps = {
4
+ title?: string;
5
+ subtitle?: string;
6
+ /** Legend is shown for 2+ items; clicking toggles visibility. */
7
+ items?: LegendItem[];
8
+ ontoggle?: (name: string) => void;
9
+ plot: Snippet<[width: number]>;
10
+ /** Table alternative — every value reachable without hover. */
11
+ table: Snippet;
12
+ };
13
+ declare const ChartFrame: import("svelte").Component<$$ComponentProps, {}, "">;
14
+ type ChartFrame = ReturnType<typeof ChartFrame>;
15
+ export default ChartFrame;
@@ -0,0 +1,14 @@
1
+ type $$ComponentProps = {
2
+ slices: {
3
+ name: string;
4
+ value: number;
5
+ }[];
6
+ title?: string;
7
+ subtitle?: string;
8
+ size?: number;
9
+ format?: (n: number) => string;
10
+ centerLabel?: string;
11
+ };
12
+ declare const DonutChart: import("svelte").Component<$$ComponentProps, {}, "">;
13
+ type DonutChart = ReturnType<typeof DonutChart>;
14
+ export default DonutChart;
@@ -0,0 +1,17 @@
1
+ type $$ComponentProps = {
2
+ values: number[];
3
+ /** Approximate bin count, or 'auto' (Sturges). Edges snap to nice numbers. */
4
+ bins?: number | 'auto';
5
+ domain?: [number, number];
6
+ title?: string;
7
+ subtitle?: string;
8
+ height?: number;
9
+ color?: string;
10
+ xFormat?: (n: number) => string;
11
+ /** Brushed selection [from, to] on the value axis (snaps to bin edges). Drag to select, click to clear. */
12
+ range?: [number, number] | null;
13
+ onbrush?: (range: [number, number] | null) => void;
14
+ };
15
+ declare const Histogram: import("svelte").Component<$$ComponentProps, {}, "range">;
16
+ type Histogram = ReturnType<typeof Histogram>;
17
+ export default Histogram;
@@ -0,0 +1,18 @@
1
+ import type { Series } from './types.js';
2
+ type $$ComponentProps = {
3
+ /** Shared x positions: numbers or Dates. */
4
+ x: (number | Date)[];
5
+ /** Max 8 (fixed-order palette, never cycled). Fold extras into "Other" upstream. */
6
+ series: Series[];
7
+ title?: string;
8
+ subtitle?: string;
9
+ height?: number;
10
+ area?: boolean;
11
+ zeroBaseline?: boolean;
12
+ /** Name labels at line ends when ≤ 4 series. */
13
+ directLabels?: boolean;
14
+ yFormat?: (n: number) => string;
15
+ };
16
+ declare const LineChart: import("svelte").Component<$$ComponentProps, {}, "">;
17
+ type LineChart = ReturnType<typeof LineChart>;
18
+ export default LineChart;
@@ -0,0 +1,10 @@
1
+ type $$ComponentProps = {
2
+ values: (number | null)[];
3
+ width?: number;
4
+ height?: number;
5
+ color?: string;
6
+ label?: string;
7
+ };
8
+ declare const Sparkline: import("svelte").Component<$$ComponentProps, {}, "">;
9
+ type Sparkline = ReturnType<typeof Sparkline>;
10
+ export default Sparkline;
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ children: Snippet;
7
+ };
8
+ declare const Tooltip: import("svelte").Component<$$ComponentProps, {}, "">;
9
+ type Tooltip = ReturnType<typeof Tooltip>;
10
+ export default Tooltip;
@@ -0,0 +1,7 @@
1
+ export { default as LineChart } from './LineChart.svelte';
2
+ export { default as BarChart } from './BarChart.svelte';
3
+ export { default as DonutChart } from './DonutChart.svelte';
4
+ export { default as Histogram } from './Histogram.svelte';
5
+ export { default as Sparkline } from './Sparkline.svelte';
6
+ export { seriesColor, niceTicks, linear } from './util.js';
7
+ export type { Series } from './types.js';
@@ -0,0 +1,9 @@
1
+ export type Series = {
2
+ name: string;
3
+ values: (number | null)[];
4
+ };
5
+ export type LegendItem = {
6
+ name: string;
7
+ color: string;
8
+ hidden?: boolean;
9
+ };
package/dist/util.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ export declare const MAX_SERIES = 8;
2
+ /** Color follows the entity (its index in the full series list), never its rank among visible ones. */
3
+ export declare const seriesColor: (i: number) => string;
4
+ export declare const linear: (d0: number, d1: number, r0: number, r1: number) => (v: number) => number;
5
+ export declare function niceTicks(min: number, max: number, count?: number): {
6
+ ticks: number[];
7
+ min: number;
8
+ max: number;
9
+ };
10
+ export declare const fmtAxis: (n: number) => string;
11
+ export declare const fmtValue: (n: number) => string;
12
+ export declare function fmtX(v: number, span: number, isDate: boolean): string;
13
+ /** Spread label y-positions so they are at least `gap` apart, preserving order. */
14
+ export declare function spreadLabels(ys: number[], gap: number, lo: number, hi: number): number[];
15
+ /** Bar with a rounded data-end, square against the baseline. `y0` is the baseline, `y1` the data end. */
16
+ export declare function barPath(x: number, y0: number, y1: number, w: number, r: number, round?: boolean): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruckc/truss-chart",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Zero-dependency SVG charts for Truss UI",
5
5
  "type": "module",
6
6
  "license": "MIT",