apexsankey 1.6.0 → 1.7.0

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 (44) hide show
  1. package/.github/workflows/publish.yml +8 -5
  2. package/README.md +39 -29
  3. package/apexsankey.d.ts +472 -0
  4. package/package.json +4 -4
  5. package/CHANGELOG.md +0 -14
  6. package/LICENSE +0 -80
  7. package/index.d.ts +0 -4
  8. package/lib/a11y/SankeyA11y.d.ts +0 -51
  9. package/lib/graph/Graph.d.ts +0 -35
  10. package/lib/layout/edgeOrdering/index.d.ts +0 -1
  11. package/lib/layout/edgeOrdering/linkDirection.d.ts +0 -1
  12. package/lib/layout/edgeOrdering/linkTypeOrder.d.ts +0 -1
  13. package/lib/layout/edgeOrdering/orderEdges.d.ts +0 -14
  14. package/lib/layout/edgePositioning/index.d.ts +0 -1
  15. package/lib/layout/edgePositioning/linkLayout.d.ts +0 -4
  16. package/lib/layout/edgePositioning/utils.d.ts +0 -10
  17. package/lib/layout/layout.d.ts +0 -71
  18. package/lib/layout/nodeOrdering/addDummyNodes.d.ts +0 -4
  19. package/lib/layout/nodeOrdering/countCrossings.d.ts +0 -31
  20. package/lib/layout/nodeOrdering/index.d.ts +0 -2
  21. package/lib/layout/nodeOrdering/initialOrdering.d.ts +0 -3
  22. package/lib/layout/nodeOrdering/ordering.d.ts +0 -12
  23. package/lib/layout/nodeOrdering/swapNodes.d.ts +0 -3
  24. package/lib/layout/nodeOrdering/weightedMedian.d.ts +0 -9
  25. package/lib/layout/nodePositioning/horizontal.d.ts +0 -4
  26. package/lib/layout/nodePositioning/index.d.ts +0 -2
  27. package/lib/layout/nodePositioning/justified.d.ts +0 -63
  28. package/lib/layout/rankAssignment/assignRanks.d.ts +0 -6
  29. package/lib/layout/rankAssignment/groupedGraph.d.ts +0 -10
  30. package/lib/layout/rankAssignment/index.d.ts +0 -1
  31. package/lib/layout/rankAssignment/initialRank.d.ts +0 -6
  32. package/lib/layout/rankAssignment/makeAcyclic.d.ts +0 -12
  33. package/lib/layout/types.d.ts +0 -99
  34. package/lib/layout/utils.d.ts +0 -13
  35. package/lib/models/ColorPalette.d.ts +0 -4
  36. package/lib/models/Edge.d.ts +0 -17
  37. package/lib/models/Graph.d.ts +0 -43
  38. package/lib/models/Node.d.ts +0 -16
  39. package/lib/models/Options.d.ts +0 -94
  40. package/lib/models/Paper.d.ts +0 -19
  41. package/lib/models/PathHighlighter.d.ts +0 -28
  42. package/lib/models/SankeyAnimation.d.ts +0 -12
  43. package/lib/sankey.d.ts +0 -13
  44. package/lib/utils/cssVars.d.ts +0 -29
@@ -1,16 +0,0 @@
1
- import { FontOptions, NodeOptions, NodeTooltipContent } from './Options';
2
- import { NodeLabel } from '../layout/types';
3
- import { G, ChartContext } from '../../../../graph-utils/src/index.ts';
4
-
5
- export interface NodeTooltipOptions {
6
- chartContext: ChartContext;
7
- nodeValue: number;
8
- tooltipBGColor: string;
9
- tooltipBorderColor: string;
10
- tooltipFontColor: string;
11
- tooltipId: string;
12
- nodeTooltipTemplate: (content: NodeTooltipContent) => string;
13
- }
14
- export declare function renderNode(graphNode: NodeLabel, maxRank: number, options: Partial<FontOptions & NodeOptions & {
15
- nodeTooltip?: NodeTooltipOptions;
16
- }>): G;
@@ -1,94 +0,0 @@
1
- import { NodeData } from '../layout/types';
2
-
3
- /** Options for WCAG 2.1 AA accessibility support */
4
- export interface A11yOptions {
5
- readonly a11y?: {
6
- /** Whether accessibility features are enabled. Default: true */
7
- readonly enabled?: boolean;
8
- /** Overrides the auto-generated aria-label on the SVG root */
9
- readonly diagramLabel?: string;
10
- /** Populates the <desc> element for a longer optional description */
11
- readonly description?: string;
12
- };
13
- }
14
- /** Data passed to the onNodeClick callback */
15
- export interface SankeyNode {
16
- value?: number;
17
- dy?: number;
18
- y?: number;
19
- x?: number;
20
- rank?: number;
21
- spaceAbove?: number;
22
- spaceBelow?: number;
23
- direction?: string;
24
- data?: NodeData | null;
25
- }
26
- /** Data passed to the tooltipTemplate callback */
27
- export interface TooltipContent {
28
- source?: NodeData | null;
29
- target?: NodeData | null;
30
- value?: number;
31
- }
32
- /** Data passed to the nodeTooltipTemplate callback */
33
- export interface NodeTooltipContent {
34
- node?: NodeData | null;
35
- value?: number;
36
- }
37
- export interface CommonOptions {
38
- readonly canvasStyle: string;
39
- readonly enableToolbar: boolean;
40
- readonly height: number | string;
41
- readonly spacing: number;
42
- readonly viewPortHeight: number;
43
- readonly viewPortWidth: number;
44
- readonly width: number | string;
45
- }
46
- export interface NodeOptions {
47
- readonly nodeBorderColor: string | null;
48
- readonly nodeBorderWidth: number;
49
- readonly nodeWidth: number;
50
- readonly onNodeClick?: (node: SankeyNode) => void;
51
- }
52
- export interface EdgeOptions {
53
- readonly edgeGap: number;
54
- readonly edgeGradientFill: boolean;
55
- readonly edgeOpacity: number;
56
- }
57
- export interface LayoutOptions {
58
- readonly whitespace: number;
59
- }
60
- export interface FontOptions {
61
- readonly fontColor: string;
62
- readonly fontFamily: string;
63
- readonly fontSize: string;
64
- readonly fontWeight: string;
65
- }
66
- export interface TooltipOptions {
67
- readonly enableTooltip: boolean;
68
- readonly tooltipBGColor: string;
69
- readonly tooltipBorderColor: string;
70
- readonly tooltipFontColor: string;
71
- readonly tooltipId: string;
72
- /** 'light' | 'dark' — overrides tooltipBGColor/tooltipBorderColor/tooltipFontColor with built-in presets */
73
- readonly tooltipTheme?: 'dark' | 'light';
74
- readonly tooltipTemplate?: (content: TooltipContent) => string;
75
- readonly nodeTooltipTemplate?: (content: NodeTooltipContent) => string;
76
- }
77
- /** Options for connected path highlighting on hover */
78
- export interface InteractionOptions {
79
- /** When true, hovering a node or edge highlights the connected flow path. Default: true */
80
- readonly highlightConnectedPath: boolean;
81
- /** Opacity for dimmed (unrelated) elements when path highlighting is active. Default: 0.15 */
82
- readonly dimOpacity: number;
83
- }
84
- /** Options for entrance animation */
85
- export interface AnimationOptions {
86
- readonly animation: {
87
- /** Whether entrance animation is enabled. Automatically disabled when prefers-reduced-motion is set. Default: true */
88
- readonly enabled: boolean;
89
- /** Total duration of the animation in milliseconds. Default: 800 */
90
- readonly duration: number;
91
- };
92
- }
93
- export type SankeyOptions = CommonOptions & EdgeOptions & FontOptions & InteractionOptions & AnimationOptions & LayoutOptions & NodeOptions & TooltipOptions & A11yOptions;
94
- export declare const DefaultOptions: SankeyOptions;
@@ -1,19 +0,0 @@
1
- import { SankeyOptions } from './Options';
2
- import { ChartContext, SvgCanvas as Svg, WrappedEl } from '../../../../graph-utils/src/index.ts';
3
-
4
- export declare class Paper {
5
- element: HTMLElement;
6
- options: SankeyOptions;
7
- protected chartContext: ChartContext;
8
- canvas: Svg;
9
- constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext);
10
- private getYShift;
11
- add(element: WrappedEl): void;
12
- clear(): void;
13
- exportToSvg(): void;
14
- resetViewBox(): void;
15
- updateViewBox(x: number, y: number, width: number, height: number): void;
16
- get height(): number;
17
- get spacing(): number;
18
- get width(): number;
19
- }
@@ -1,28 +0,0 @@
1
- import { SankeyGraph as SankeyGraphLayout } from '../layout/types';
2
-
3
- /**
4
- * Highlights the connected flow path when hovering a node or edge in the Sankey diagram.
5
- * Dims unrelated elements and brightens the hovered element and its connected chain.
6
- * Respects `prefers-reduced-motion` by skipping opacity transitions when active.
7
- */
8
- export declare class PathHighlighter {
9
- private readonly svgRoot;
10
- private readonly graph;
11
- private readonly dimOpacity;
12
- constructor(svgRoot: SVGElement, graph: SankeyGraphLayout, dimOpacity: number);
13
- /**
14
- * Dims all unrelated elements and highlights the given node plus all directly
15
- * connected edges and nodes (one hop away).
16
- */
17
- highlightNode(nodeId: string): void;
18
- /**
19
- * Dims all unrelated elements and highlights the hovered edge along with its
20
- * real source and target nodes.
21
- */
22
- highlightEdge(sourceId: string, targetId: string): void;
23
- /** Restores all edges and nodes to their original (pre-highlight) opacity. */
24
- reset(): void;
25
- private dimAll;
26
- private setOpacity;
27
- private prefersReducedMotion;
28
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Plays a left-to-right entrance animation on the Sankey chart using the Web Animations API.
3
- *
4
- * Two things happen simultaneously:
5
- * 1. A clipPath rect sweeps left → right via rAF-driven setAttribute (WAAPI cannot animate
6
- * SVG presentation attributes directly — the `width` keyframe is rejected in all browsers).
7
- * 2. Each node column fades + slides in, staggered by rank so earlier columns appear first.
8
- * Nodes start hidden via inline style so there is no flicker before the delay fires.
9
- *
10
- * Respects `prefers-reduced-motion`: skipped entirely when the media query matches.
11
- */
12
- export declare function playSankeyAnimation(svgEl: SVGSVGElement, edgesGroup: SVGElement, nodesGroup: SVGElement, maxRank: number, duration: number): void;
package/lib/sankey.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { SankeyOptions } from './models/Options';
2
- import { GraphData, SankeyGraph } from './models/Graph';
3
- import { BaseChart } from '../../../graph-utils/src/index.ts';
4
-
5
- export declare class ApexSankey extends BaseChart {
6
- graph: SankeyGraph;
7
- options: SankeyOptions;
8
- constructor(element: HTMLElement, options?: Partial<SankeyOptions>);
9
- static setLicense(key: string): void;
10
- private setupElementDimensions;
11
- private handleWatermark;
12
- render(data: GraphData): SankeyGraph;
13
- }
@@ -1,29 +0,0 @@
1
- import { SankeyOptions } from '../models/Options';
2
-
3
- /**
4
- * Reads a CSS custom property value from an element using getComputedStyle.
5
- * Returns an empty string if the property is not set.
6
- */
7
- export declare function readCSSVar(element: HTMLElement, name: string): string;
8
- /**
9
- * Resolves SankeyOptions by overriding JS option values with CSS custom property
10
- * values when those properties are set on the container element.
11
- *
12
- * Supported CSS custom properties:
13
- * --apex-sankey-edge-opacity → edgeOpacity
14
- * --apex-sankey-edge-gradient → edgeGradientFill (boolean: 'true'/'false')
15
- * --apex-sankey-label-color → fontColor
16
- * --apex-sankey-label-font-size → fontSize
17
- * --apex-sankey-font-family → fontFamily
18
- * --apex-sankey-node-width → nodeWidth
19
- * --apex-sankey-node-border-color → nodeBorderColor
20
- * --apex-sankey-node-border-width → nodeBorderWidth
21
- * --apex-sankey-tooltip-bg → tooltipBGColor
22
- * --apex-sankey-tooltip-border-color → tooltipBorderColor
23
- * --apex-sankey-tooltip-font-color → tooltipFontColor
24
- * --apex-sankey-tooltip-theme → tooltipTheme ('light' | 'dark')
25
- *
26
- * CSS custom properties take precedence over JS options.
27
- * JS options serve as fallbacks when no CSS variable is present.
28
- */
29
- export declare function resolveCSSVars(element: HTMLElement, options: SankeyOptions): SankeyOptions;