@faintshadow/flarecharts 26.3.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.
Files changed (85) hide show
  1. package/LICENSE +40 -0
  2. package/README.md +103 -0
  3. package/dist/charts/AreaChart.svelte +150 -0
  4. package/dist/charts/AreaChart.svelte.d.ts +60 -0
  5. package/dist/charts/BarChart.svelte +142 -0
  6. package/dist/charts/BarChart.svelte.d.ts +58 -0
  7. package/dist/charts/BoxPlotChart.svelte +138 -0
  8. package/dist/charts/BoxPlotChart.svelte.d.ts +56 -0
  9. package/dist/charts/DonutChart.svelte +129 -0
  10. package/dist/charts/DonutChart.svelte.d.ts +73 -0
  11. package/dist/charts/LineChart.svelte +149 -0
  12. package/dist/charts/LineChart.svelte.d.ts +63 -0
  13. package/dist/charts/Sparkline.svelte +87 -0
  14. package/dist/charts/Sparkline.svelte.d.ts +40 -0
  15. package/dist/charts/StackChart.svelte +157 -0
  16. package/dist/charts/StackChart.svelte.d.ts +69 -0
  17. package/dist/components/Arc.svelte +202 -0
  18. package/dist/components/Arc.svelte.d.ts +50 -0
  19. package/dist/components/Area.svelte +264 -0
  20. package/dist/components/Area.svelte.d.ts +54 -0
  21. package/dist/components/Axis.svelte +139 -0
  22. package/dist/components/Axis.svelte.d.ts +26 -0
  23. package/dist/components/Bars.svelte +192 -0
  24. package/dist/components/Bars.svelte.d.ts +55 -0
  25. package/dist/components/Box.svelte +287 -0
  26. package/dist/components/Box.svelte.d.ts +48 -0
  27. package/dist/components/Chart.svelte +207 -0
  28. package/dist/components/Chart.svelte.d.ts +23 -0
  29. package/dist/components/Crosshair.svelte +67 -0
  30. package/dist/components/Crosshair.svelte.d.ts +14 -0
  31. package/dist/components/Grid.svelte +38 -0
  32. package/dist/components/Grid.svelte.d.ts +14 -0
  33. package/dist/components/Labels.svelte +61 -0
  34. package/dist/components/Labels.svelte.d.ts +35 -0
  35. package/dist/components/Legend.svelte +81 -0
  36. package/dist/components/Legend.svelte.d.ts +12 -0
  37. package/dist/components/Line.svelte +192 -0
  38. package/dist/components/Line.svelte.d.ts +47 -0
  39. package/dist/components/PlotBand.svelte +68 -0
  40. package/dist/components/PlotBand.svelte.d.ts +14 -0
  41. package/dist/components/PlotLine.svelte +54 -0
  42. package/dist/components/PlotLine.svelte.d.ts +16 -0
  43. package/dist/components/Points.svelte +179 -0
  44. package/dist/components/Points.svelte.d.ts +53 -0
  45. package/dist/components/Svg.svelte +36 -0
  46. package/dist/components/Svg.svelte.d.ts +8 -0
  47. package/dist/components/Tooltip.svelte +211 -0
  48. package/dist/components/Tooltip.svelte.d.ts +44 -0
  49. package/dist/core/bisect.d.ts +5 -0
  50. package/dist/core/bisect.js +23 -0
  51. package/dist/core/context.svelte.d.ts +140 -0
  52. package/dist/core/context.svelte.js +294 -0
  53. package/dist/core/curves.d.ts +4 -0
  54. package/dist/core/curves.js +13 -0
  55. package/dist/core/hit.d.ts +34 -0
  56. package/dist/core/hit.js +43 -0
  57. package/dist/core/keynav.d.ts +20 -0
  58. package/dist/core/keynav.js +41 -0
  59. package/dist/core/labels.d.ts +39 -0
  60. package/dist/core/labels.js +27 -0
  61. package/dist/core/merge.d.ts +17 -0
  62. package/dist/core/merge.js +46 -0
  63. package/dist/core/motion.svelte.d.ts +31 -0
  64. package/dist/core/motion.svelte.js +129 -0
  65. package/dist/core/normalize.d.ts +35 -0
  66. package/dist/core/normalize.js +97 -0
  67. package/dist/core/options.d.ts +113 -0
  68. package/dist/core/options.js +36 -0
  69. package/dist/core/palette.d.ts +8 -0
  70. package/dist/core/palette.js +24 -0
  71. package/dist/core/responsive.d.ts +6 -0
  72. package/dist/core/responsive.js +19 -0
  73. package/dist/core/scales.d.ts +31 -0
  74. package/dist/core/scales.js +89 -0
  75. package/dist/core/stack.d.ts +19 -0
  76. package/dist/core/stack.js +133 -0
  77. package/dist/core/stats.d.ts +45 -0
  78. package/dist/core/stats.js +114 -0
  79. package/dist/core/symbols.d.ts +8 -0
  80. package/dist/core/symbols.js +31 -0
  81. package/dist/core/types.d.ts +28 -0
  82. package/dist/core/types.js +1 -0
  83. package/dist/index.d.ts +52 -0
  84. package/dist/index.js +42 -0
  85. package/package.json +81 -0
@@ -0,0 +1,19 @@
1
+ import type { NormalizedPoint, XValue } from './normalize.js';
2
+ export interface StackInput<K = number> {
3
+ /** Caller's identifier for the series (flarechart uses the registration index). */
4
+ key: K;
5
+ points: readonly NormalizedPoint<unknown>[];
6
+ }
7
+ /** xKey (see stackKey) → [y0, y1] extents in VALUE space. */
8
+ export type StackExtents = Map<string, [number, number]>;
9
+ /** How the stack sits. normal/percent anchor at zero; stream/silhouette float. */
10
+ export type StackOffset = 'normal' | 'percent' | 'stream' | 'silhouette' | 'none';
11
+ /** Layer ordering within the stack. */
12
+ export type StackOrder = 'none' | 'ascending' | 'descending' | 'inside-out' | 'reverse' | 'appearance';
13
+ export interface StackOptions {
14
+ offset?: StackOffset;
15
+ order?: StackOrder;
16
+ }
17
+ /** Canonical map key for an x value — Date-safe (equal instants collide). */
18
+ export declare function stackKey(x: XValue): string;
19
+ export declare function stackSeries<K>(series: readonly StackInput<K>[], options?: StackOptions): Map<K, StackExtents>;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Stacking math — a first-class, configurable primitive over d3-shape's stack().
3
+ *
4
+ * Like d3, stacking is its own thing here: pick an OFFSET (how the stack sits)
5
+ * and an ORDER (the layer sequence). d3.stack() does the cumulative work; two
6
+ * adapter concerns wrap it to fit flarechart's data model:
7
+ *
8
+ * 1. Pivot — the library stores column-oriented, ragged, gappy
9
+ * NormalizedPoint[] per series; d3.stack wants a rectangular table (one row
10
+ * per x, one column per series). We union the x keys (Date-safe stackKey),
11
+ * build rows, feed gap/absent cells as 0 so they take no part, then drop
12
+ * them from the output (no entry → no bar / area break, no hole).
13
+ * 2. Percent — d3's stackOffsetExpand normalizes by the signed row total; we
14
+ * instead pre-scale values to ±100 against separate positive/negative
15
+ * totals before the diverging offset.
16
+ *
17
+ * Offsets:
18
+ * normal → diverging (positives up, negatives down from zero)
19
+ * percent → ±100 pre-scale, then diverging
20
+ * stream → wiggle (streamgraph — floats, minimized movement)
21
+ * silhouette → centered around zero (floats)
22
+ * none → plain cumulative from zero (sign-naive)
23
+ *
24
+ * Output stays in the library's [base, base+value] convention for the diverging
25
+ * offsets (a negative reads [0, -4], not d3's [-4, 0]); the floating offsets
26
+ * (stream/silhouette/none) pass d3's [lower, upper] through unchanged.
27
+ */
28
+ import { stack as d3stack, stackOffsetDiverging, stackOffsetNone, stackOffsetSilhouette, stackOffsetWiggle, stackOrderAppearance, stackOrderAscending, stackOrderDescending, stackOrderInsideOut, stackOrderNone, stackOrderReverse } from 'd3-shape';
29
+ /** Canonical map key for an x value — Date-safe (equal instants collide). */
30
+ export function stackKey(x) {
31
+ return x instanceof Date ? `t${x.getTime()}` : String(x);
32
+ }
33
+ const OFFSETS = {
34
+ normal: stackOffsetDiverging,
35
+ percent: stackOffsetDiverging,
36
+ stream: stackOffsetWiggle,
37
+ silhouette: stackOffsetSilhouette,
38
+ none: stackOffsetNone
39
+ };
40
+ const ORDERS = {
41
+ none: stackOrderNone,
42
+ ascending: stackOrderAscending,
43
+ descending: stackOrderDescending,
44
+ 'inside-out': stackOrderInsideOut,
45
+ reverse: stackOrderReverse,
46
+ appearance: stackOrderAppearance
47
+ };
48
+ export function stackSeries(series, options = {}) {
49
+ const offset = options.offset ?? 'normal';
50
+ const order = options.order ?? 'none';
51
+ // The [base, base+value] orientation flip only applies to the diverging
52
+ // offsets; the floating offsets emit d3's [lower, upper] directly.
53
+ const diverging = offset === 'normal' || offset === 'percent';
54
+ const out = new Map();
55
+ if (series.length === 0)
56
+ return out;
57
+ // Union of x keys in first-seen order, plus a per-series cell table.
58
+ // A cell is a gap until some non-null point fills it; duplicate points at
59
+ // the same x within a series sum (matching the previous accumulation).
60
+ const keyOrder = [];
61
+ const seen = new Set();
62
+ const cells = series.map((s) => {
63
+ const m = new Map();
64
+ for (const p of s.points) {
65
+ const k = stackKey(p.x);
66
+ if (!seen.has(k)) {
67
+ seen.add(k);
68
+ keyOrder.push(k);
69
+ }
70
+ const cur = m.get(k) ?? { value: 0, gap: true };
71
+ if (p.y != null) {
72
+ cur.value += p.y;
73
+ cur.gap = false;
74
+ }
75
+ m.set(k, cur);
76
+ }
77
+ return m;
78
+ });
79
+ // Percent: pre-scale to ±100 against separate positive/negative totals, so
80
+ // positives fill 0..100 and negatives 0..-100 independently at each x.
81
+ if (offset === 'percent') {
82
+ const posTotals = new Map();
83
+ const negTotals = new Map();
84
+ for (const m of cells) {
85
+ for (const [k, c] of m) {
86
+ if (c.gap)
87
+ continue;
88
+ if (c.value >= 0)
89
+ posTotals.set(k, (posTotals.get(k) ?? 0) + c.value);
90
+ else
91
+ negTotals.set(k, (negTotals.get(k) ?? 0) + Math.abs(c.value));
92
+ }
93
+ }
94
+ for (const m of cells) {
95
+ for (const [k, c] of m) {
96
+ if (c.gap)
97
+ continue;
98
+ const total = c.value >= 0 ? posTotals.get(k) : negTotals.get(k);
99
+ c.value = !total ? 0 : (c.value / total) * 100;
100
+ }
101
+ }
102
+ }
103
+ // Pivot to a rectangular table keyed by series index; gaps contribute 0.
104
+ const idxKeys = series.map((_, i) => String(i));
105
+ const rows = keyOrder.map((xKey) => {
106
+ const row = {};
107
+ cells.forEach((m, i) => {
108
+ const c = m.get(xKey);
109
+ row[String(i)] = c && !c.gap ? c.value : 0;
110
+ });
111
+ return row;
112
+ });
113
+ const stacked = d3stack()
114
+ .keys(idxKeys)
115
+ .value((row, key) => row[key] ?? 0)
116
+ .order(ORDERS[order])
117
+ .offset(OFFSETS[offset])(rows);
118
+ // Map back: drop gap cells; flip negatives to [base, base+value] for the
119
+ // diverging offsets (d3 emits [lower, upper]).
120
+ stacked.forEach((layer, i) => {
121
+ const extents = new Map();
122
+ const m = cells[i];
123
+ layer.forEach((pt, rowIdx) => {
124
+ const xKey = keyOrder[rowIdx];
125
+ const c = m.get(xKey);
126
+ if (!c || c.gap)
127
+ return;
128
+ extents.set(xKey, diverging && c.value < 0 ? [pt[1], pt[0]] : [pt[0], pt[1]]);
129
+ });
130
+ out.set(series[i].key, extents);
131
+ });
132
+ return out;
133
+ }
@@ -0,0 +1,45 @@
1
+ export interface FiveNumber {
2
+ min: number;
3
+ q1: number;
4
+ median: number;
5
+ q3: number;
6
+ max: number;
7
+ }
8
+ /** Five-number summary from raw samples, or null if there are no finite values. */
9
+ export declare function fiveNumber(samples: readonly number[]): FiveNumber | null;
10
+ export interface BoxStats {
11
+ q1: number;
12
+ median: number;
13
+ q3: number;
14
+ /** Whisker ends — Tukey-clamped or data min/max per `whisker`. */
15
+ low: number;
16
+ high: number;
17
+ /** Samples outside the whiskers (always empty for 'minmax'). */
18
+ outliers: number[];
19
+ }
20
+ export type WhiskerMode = 'tukey' | 'minmax';
21
+ /** Full box statistics from raw samples, or null if there are no finite values. */
22
+ export declare function boxStats(samples: readonly number[], options?: {
23
+ whisker?: WhiskerMode;
24
+ k?: number;
25
+ }): BoxStats | null;
26
+ export interface BoxAccessors<T = unknown> {
27
+ low?: (datum: T, index: number) => number | null | undefined;
28
+ q1?: (datum: T, index: number) => number | null | undefined;
29
+ median?: (datum: T, index: number) => number | null | undefined;
30
+ q3?: (datum: T, index: number) => number | null | undefined;
31
+ high?: (datum: T, index: number) => number | null | undefined;
32
+ outliers?: (datum: T, index: number) => readonly number[] | undefined;
33
+ samples?: (datum: T, index: number) => readonly number[] | undefined;
34
+ }
35
+ /**
36
+ * Resolve one datum to BoxStats. Precedence:
37
+ * 1. `samples` accessor → boxStats(samples)
38
+ * 2. precomputed accessors (low/q1/median/q3/high[/outliers])
39
+ * 3. inferred from datum shape: 5-/6-tuple or { low,q1,median,q3,high,outliers? }
40
+ * Returns null if a required value is missing or non-finite.
41
+ */
42
+ export declare function resolveBoxStats<T>(datum: T, index: number, accessors: BoxAccessors<T>, options?: {
43
+ whisker?: WhiskerMode;
44
+ k?: number;
45
+ }): BoxStats | null;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Box-plot statistics — pure, DOM-free, Vitest-tested (like stack.ts / hit.ts).
3
+ * The only d3 touched here is d3-array's `quantileSorted` (math only).
4
+ */
5
+ import { quantileSorted } from 'd3-array';
6
+ /** Drop non-finite values and return a sorted copy. */
7
+ function clean(samples) {
8
+ const out = [];
9
+ for (const v of samples) {
10
+ if (typeof v === 'number' && Number.isFinite(v))
11
+ out.push(v);
12
+ }
13
+ out.sort((a, b) => a - b);
14
+ return out;
15
+ }
16
+ /** Five-number summary from raw samples, or null if there are no finite values. */
17
+ export function fiveNumber(samples) {
18
+ const s = clean(samples);
19
+ if (s.length === 0)
20
+ return null;
21
+ return {
22
+ min: s[0],
23
+ q1: quantileSorted(s, 0.25),
24
+ median: quantileSorted(s, 0.5),
25
+ q3: quantileSorted(s, 0.75),
26
+ max: s[s.length - 1]
27
+ };
28
+ }
29
+ /** Full box statistics from raw samples, or null if there are no finite values. */
30
+ export function boxStats(samples, options = {}) {
31
+ const s = clean(samples);
32
+ if (s.length === 0)
33
+ return null;
34
+ const { whisker = 'tukey', k = 1.5 } = options;
35
+ const q1 = quantileSorted(s, 0.25);
36
+ const median = quantileSorted(s, 0.5);
37
+ const q3 = quantileSorted(s, 0.75);
38
+ if (whisker === 'minmax') {
39
+ return { q1, median, q3, low: s[0], high: s[s.length - 1], outliers: [] };
40
+ }
41
+ const iqr = q3 - q1;
42
+ const loFence = q1 - k * iqr;
43
+ const hiFence = q3 + k * iqr;
44
+ // s is sorted: low = first value within the fence, high = last value within it.
45
+ let low = s[0];
46
+ for (const v of s) {
47
+ if (v >= loFence) {
48
+ low = v;
49
+ break;
50
+ }
51
+ }
52
+ let high = s[s.length - 1];
53
+ for (let i = s.length - 1; i >= 0; i--) {
54
+ if (s[i] <= hiFence) {
55
+ high = s[i];
56
+ break;
57
+ }
58
+ }
59
+ const outliers = [];
60
+ for (const v of s) {
61
+ if (v < low || v > high)
62
+ outliers.push(v);
63
+ }
64
+ return { q1, median, q3, low, high, outliers };
65
+ }
66
+ const finite = (v) => typeof v === 'number' && Number.isFinite(v) ? v : null;
67
+ const finiteList = (v) => Array.isArray(v) ? v.filter((n) => typeof n === 'number' && Number.isFinite(n)) : [];
68
+ /**
69
+ * Resolve one datum to BoxStats. Precedence:
70
+ * 1. `samples` accessor → boxStats(samples)
71
+ * 2. precomputed accessors (low/q1/median/q3/high[/outliers])
72
+ * 3. inferred from datum shape: 5-/6-tuple or { low,q1,median,q3,high,outliers? }
73
+ * Returns null if a required value is missing or non-finite.
74
+ */
75
+ export function resolveBoxStats(datum, index, accessors, options = {}) {
76
+ const samples = accessors.samples?.(datum, index);
77
+ if (samples)
78
+ return boxStats(samples, options);
79
+ if (accessors.median || accessors.q1 || accessors.q3) {
80
+ const q1 = finite(accessors.q1?.(datum, index));
81
+ const median = finite(accessors.median?.(datum, index));
82
+ const q3 = finite(accessors.q3?.(datum, index));
83
+ const low = finite(accessors.low?.(datum, index));
84
+ const high = finite(accessors.high?.(datum, index));
85
+ if (q1 == null || median == null || q3 == null || low == null || high == null)
86
+ return null;
87
+ return { low, q1, median, q3, high, outliers: finiteList(accessors.outliers?.(datum, index)) };
88
+ }
89
+ if (Array.isArray(datum)) {
90
+ const offset = datum.length >= 6 ? 1 : 0; // 6-tuple => x is at [0]
91
+ if (datum.length < 5 + offset)
92
+ return null;
93
+ const low = finite(datum[offset]);
94
+ const q1 = finite(datum[offset + 1]);
95
+ const median = finite(datum[offset + 2]);
96
+ const q3 = finite(datum[offset + 3]);
97
+ const high = finite(datum[offset + 4]);
98
+ if (low == null || q1 == null || median == null || q3 == null || high == null)
99
+ return null;
100
+ return { low, q1, median, q3, high, outliers: [] };
101
+ }
102
+ if (datum && typeof datum === 'object') {
103
+ const o = datum;
104
+ const low = finite(o.low);
105
+ const q1 = finite(o.q1);
106
+ const median = finite(o.median);
107
+ const q3 = finite(o.q3);
108
+ const high = finite(o.high);
109
+ if (low == null || q1 == null || median == null || q3 == null || high == null)
110
+ return null;
111
+ return { low, q1, median, q3, high, outliers: finiteList(o.outliers) };
112
+ }
113
+ return null;
114
+ }
@@ -0,0 +1,8 @@
1
+ import type { SymbolType } from 'd3-shape';
2
+ export type SymbolName = 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
3
+ /** Resolve a symbol by name, or pass a d3 SymbolType straight through. */
4
+ export declare function symbolFor(symbol?: SymbolName | SymbolType): SymbolType;
5
+ /** Pick a symbol from the default cycle by series index. */
6
+ export declare function symbolByIndex(index: number): SymbolType;
7
+ /** Generate the SVG path `d` string for a symbol at the origin. */
8
+ export declare function symbolPath(type: SymbolType, size?: number): string;
@@ -0,0 +1,31 @@
1
+ import { symbol as d3symbol, symbolCircle, symbolCross, symbolDiamond, symbolSquare, symbolStar, symbolTriangle, symbolWye } from 'd3-shape';
2
+ const SYMBOLS = {
3
+ circle: symbolCircle,
4
+ cross: symbolCross,
5
+ diamond: symbolDiamond,
6
+ square: symbolSquare,
7
+ star: symbolStar,
8
+ triangle: symbolTriangle,
9
+ wye: symbolWye
10
+ };
11
+ const SYMBOL_CYCLE = [
12
+ 'circle',
13
+ 'diamond',
14
+ 'square',
15
+ 'triangle',
16
+ 'star',
17
+ 'cross',
18
+ 'wye'
19
+ ];
20
+ /** Resolve a symbol by name, or pass a d3 SymbolType straight through. */
21
+ export function symbolFor(symbol = 'circle') {
22
+ return typeof symbol === 'string' ? SYMBOLS[symbol] : symbol;
23
+ }
24
+ /** Pick a symbol from the default cycle by series index. */
25
+ export function symbolByIndex(index) {
26
+ return SYMBOLS[SYMBOL_CYCLE[index % SYMBOL_CYCLE.length]];
27
+ }
28
+ /** Generate the SVG path `d` string for a symbol at the origin. */
29
+ export function symbolPath(type, size = 64) {
30
+ return d3symbol().type(type).size(size)() ?? '';
31
+ }
@@ -0,0 +1,28 @@
1
+ import type { ScaleKind } from './scales.js';
2
+ export interface Padding {
3
+ top?: number;
4
+ right?: number;
5
+ bottom?: number;
6
+ left?: number;
7
+ }
8
+ export interface AxisOptions {
9
+ /** Scale type. Omit to infer from data: Date → time, string → band, else linear. */
10
+ type?: ScaleKind;
11
+ /** Pin the domain start (continuous scales). Omit/undefined → from data. */
12
+ min?: number | Date;
13
+ /** Pin the domain end (continuous scales). Omit/undefined → from data. */
14
+ max?: number | Date;
15
+ /** Band scales: explicit category order. Omit → unique x values in data order. */
16
+ categories?: string[];
17
+ /** `true` (default) → nice domain; a number → tick count hint; `false` → exact. */
18
+ nice?: boolean | number;
19
+ /** Force the domain to include zero (off by default). */
20
+ includeZero?: boolean;
21
+ /** Band scales: inner padding ratio (default 0.1). */
22
+ bandPadding?: number;
23
+ }
24
+ export interface ChartOptions {
25
+ padding?: Padding;
26
+ x?: AxisOptions;
27
+ y?: AxisOptions;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ export { default as Chart } from './components/Chart.svelte';
2
+ export { default as Svg } from './components/Svg.svelte';
3
+ export { default as Axis } from './components/Axis.svelte';
4
+ export { default as Grid } from './components/Grid.svelte';
5
+ export { default as Line } from './components/Line.svelte';
6
+ export { default as Area } from './components/Area.svelte';
7
+ export { default as Points } from './components/Points.svelte';
8
+ export { default as Bars } from './components/Bars.svelte';
9
+ export { default as PlotBand } from './components/PlotBand.svelte';
10
+ export { default as PlotLine } from './components/PlotLine.svelte';
11
+ export { default as Tooltip } from './components/Tooltip.svelte';
12
+ export { default as Crosshair } from './components/Crosshair.svelte';
13
+ export { default as Legend } from './components/Legend.svelte';
14
+ export { default as Arc } from './components/Arc.svelte';
15
+ export { default as Labels } from './components/Labels.svelte';
16
+ export { default as Box } from './components/Box.svelte';
17
+ export { default as Sparkline } from './charts/Sparkline.svelte';
18
+ export { default as LineChart } from './charts/LineChart.svelte';
19
+ export { default as AreaChart } from './charts/AreaChart.svelte';
20
+ export { default as BarChart } from './charts/BarChart.svelte';
21
+ export { default as DonutChart } from './charts/DonutChart.svelte';
22
+ export { default as StackChart } from './charts/StackChart.svelte';
23
+ export { default as BoxPlotChart } from './charts/BoxPlotChart.svelte';
24
+ export { ChartContext, getChartContext, setChartContext } from './core/context.svelte.js';
25
+ export type { RegisteredSeries, SeriesEntry, SeriesRegistration, StackedSeriesOptions } from './core/context.svelte.js';
26
+ export { stackKey, stackSeries } from './core/stack.js';
27
+ export type { StackExtents, StackInput, StackOffset, StackOptions, StackOrder } from './core/stack.js';
28
+ export { placeLabels } from './core/labels.js';
29
+ export type { LabelCandidate, LabelPlacementOptions, PlacedLabel } from './core/labels.js';
30
+ export { SERIES_DEFAULTS, resolveSeries, splitAxisOptions } from './core/options.js';
31
+ export type { BandSpec, LegendSpec, PlotLineSpec, PlotOptions, ResolvedSeries, SeriesOptions, MarkerMode, SimpleAxisOptions, TooltipSpec } from './core/options.js';
32
+ export { applyResponsive } from './core/responsive.js';
33
+ export type { ResponsiveRule } from './core/responsive.js';
34
+ export { moveFocus } from './core/keynav.js';
35
+ export type { KeyNavPosition, KeyNavSeries } from './core/keynav.js';
36
+ export { bisectNearest } from './core/bisect.js';
37
+ export { hitBisectX, hitNearest, hitsAtBand } from './core/hit.js';
38
+ export type { HitResult, TooltipData, TooltipMode, TooltipPoint } from './core/hit.js';
39
+ export { normalizePoints, xKindOf } from './core/normalize.js';
40
+ export type { NormalizedPoint, PointAccessors, XValue } from './core/normalize.js';
41
+ export { mergeOptions } from './core/merge.js';
42
+ export { bandInvert, createScale, isBandScale, scalePos, scaleTicks, scaleTickFormat } from './core/scales.js';
43
+ export type { AnyScale, ScaleDomain, ScaleKind, ScaleSpec } from './core/scales.js';
44
+ export { curveFor } from './core/curves.js';
45
+ export type { CurveName } from './core/curves.js';
46
+ export { symbolFor, symbolByIndex, symbolPath } from './core/symbols.js';
47
+ export type { SymbolName } from './core/symbols.js';
48
+ export { DEFAULT_PALETTE, seriesColorVar } from './core/palette.js';
49
+ export { fiveNumber, boxStats, resolveBoxStats } from './core/stats.js';
50
+ export type { FiveNumber, BoxStats, WhiskerMode, BoxAccessors } from './core/stats.js';
51
+ export { prefersReducedMotion, parseDuration, motionDuration, boxEnterPhases } from './core/motion.svelte.js';
52
+ export type { AxisOptions, ChartOptions, Padding } from './core/types.js';
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ // L1 primitives
2
+ export { default as Chart } from './components/Chart.svelte';
3
+ export { default as Svg } from './components/Svg.svelte';
4
+ export { default as Axis } from './components/Axis.svelte';
5
+ export { default as Grid } from './components/Grid.svelte';
6
+ export { default as Line } from './components/Line.svelte';
7
+ export { default as Area } from './components/Area.svelte';
8
+ export { default as Points } from './components/Points.svelte';
9
+ export { default as Bars } from './components/Bars.svelte';
10
+ export { default as PlotBand } from './components/PlotBand.svelte';
11
+ export { default as PlotLine } from './components/PlotLine.svelte';
12
+ export { default as Tooltip } from './components/Tooltip.svelte';
13
+ export { default as Crosshair } from './components/Crosshair.svelte';
14
+ export { default as Legend } from './components/Legend.svelte';
15
+ export { default as Arc } from './components/Arc.svelte';
16
+ export { default as Labels } from './components/Labels.svelte';
17
+ export { default as Box } from './components/Box.svelte';
18
+ // L2 simple charts (built only from L1)
19
+ export { default as Sparkline } from './charts/Sparkline.svelte';
20
+ export { default as LineChart } from './charts/LineChart.svelte';
21
+ export { default as AreaChart } from './charts/AreaChart.svelte';
22
+ export { default as BarChart } from './charts/BarChart.svelte';
23
+ export { default as DonutChart } from './charts/DonutChart.svelte';
24
+ export { default as StackChart } from './charts/StackChart.svelte';
25
+ export { default as BoxPlotChart } from './charts/BoxPlotChart.svelte';
26
+ // Core (the math under the components — public, tested, tree-shakeable)
27
+ export { ChartContext, getChartContext, setChartContext } from './core/context.svelte.js';
28
+ export { stackKey, stackSeries } from './core/stack.js';
29
+ export { placeLabels } from './core/labels.js';
30
+ export { SERIES_DEFAULTS, resolveSeries, splitAxisOptions } from './core/options.js';
31
+ export { applyResponsive } from './core/responsive.js';
32
+ export { moveFocus } from './core/keynav.js';
33
+ export { bisectNearest } from './core/bisect.js';
34
+ export { hitBisectX, hitNearest, hitsAtBand } from './core/hit.js';
35
+ export { normalizePoints, xKindOf } from './core/normalize.js';
36
+ export { mergeOptions } from './core/merge.js';
37
+ export { bandInvert, createScale, isBandScale, scalePos, scaleTicks, scaleTickFormat } from './core/scales.js';
38
+ export { curveFor } from './core/curves.js';
39
+ export { symbolFor, symbolByIndex, symbolPath } from './core/symbols.js';
40
+ export { DEFAULT_PALETTE, seriesColorVar } from './core/palette.js';
41
+ export { fiveNumber, boxStats, resolveBoxStats } from './core/stats.js';
42
+ export { prefersReducedMotion, parseDuration, motionDuration, boxEnterPhases } from './core/motion.svelte.js';
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@faintshadow/flarecharts",
3
+ "version": "26.3.1",
4
+ "description": "Composable, runes-first SVG charting library for Svelte 5. CSS-variable theming, typed snippets, accessible by default.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "author": "Safwen TBINI <https://form.typeform.com/to/HjsO4h0K>",
7
+ "homepage": "https://faintshadow.gitlab.io/flarecharts/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://gitlab.com/FaintShadow/flarecharts.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://gitlab.com/FaintShadow/flarecharts/-/boards"
14
+ },
15
+ "type": "module",
16
+ "scripts": {
17
+ "dev": "vite dev",
18
+ "build": "vite build",
19
+ "preview": "vite preview",
20
+ "package": "svelte-kit sync && svelte-package && publint",
21
+ "prepublishOnly": "npm run package",
22
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "prepare": "svelte-kit sync",
26
+ "version:stamp": "node scripts/version-stamp.mjs"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "!dist/**/*.test.*",
31
+ "!dist/**/*.spec.*"
32
+ ],
33
+ "sideEffects": false,
34
+ "svelte": "./dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "svelte": "./dist/index.js",
40
+ "default": "./dist/index.js"
41
+ }
42
+ },
43
+ "peerDependencies": {
44
+ "svelte": "^5.0.0"
45
+ },
46
+ "dependencies": {
47
+ "d3-array": "^3.2.4",
48
+ "d3-interpolate-path": "^2.3.0",
49
+ "d3-scale": "^4.0.2",
50
+ "d3-shape": "^3.2.0",
51
+ "d3-time": "^3.1.0"
52
+ },
53
+ "devDependencies": {
54
+ "@sveltejs/adapter-auto": "^3.3.1",
55
+ "@sveltejs/adapter-static": "^3.0.10",
56
+ "@sveltejs/kit": "^2.20.0",
57
+ "@sveltejs/package": "^2.3.10",
58
+ "@sveltejs/vite-plugin-svelte": "^5.0.0",
59
+ "@types/d3-array": "^3.2.1",
60
+ "@types/d3-interpolate-path": "^2.0.3",
61
+ "@types/d3-scale": "^4.0.9",
62
+ "@types/d3-shape": "^3.1.7",
63
+ "@types/d3-time": "^3.0.4",
64
+ "@types/node": "^22.0.0",
65
+ "publint": "^0.3.0",
66
+ "svelte": "^5.30.0",
67
+ "svelte-check": "^4.1.0",
68
+ "typescript": "^5.8.0",
69
+ "vite": "^6.2.0",
70
+ "vitest": "^3.1.0"
71
+ },
72
+ "keywords": [
73
+ "svelte",
74
+ "svelte5",
75
+ "charts",
76
+ "charting",
77
+ "svg",
78
+ "dataviz",
79
+ "runes"
80
+ ]
81
+ }