apexsankey 1.1.2 → 1.1.3

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.
@@ -1,4 +1,5 @@
1
1
  import { Graph } from 'graphlib';
2
+
2
3
  /**
3
4
  * Reverse edges in G to make it acyclic
4
5
  */
@@ -8,4 +9,4 @@ export declare function findSpanningTree(G: any, v0: any): Graph;
8
9
  * Returns 1 if w is a descendent of v, -1 if v is a descendent of w, and 0 if
9
10
  * they are unrelated.
10
11
  */
11
- export declare function nodeRelationship(tree: any, v: any, w: any): 0 | 1 | -1;
12
+ export declare function nodeRelationship(tree: any, v: any, w: any): 1 | 0 | -1;
@@ -1,2 +1,3 @@
1
1
  import { Graph } from 'graphlib';
2
+
2
3
  export declare function createGraph(nodes?: any[], edges?: any[]): Graph;
@@ -1 +1,2 @@
1
- export declare function generatePath(edge: any): string;
1
+ export declare function segmentPath(edge: any): string;
2
+ export declare function generatePath(d: any): string;
@@ -1,14 +1,16 @@
1
- import { G } from '@svgdotjs/svg.js';
2
1
  import { Paper } from './Paper';
3
2
  import { SankeyOptions } from './Options';
3
+ import { Graph } from 'graphlib';
4
+ import { G } from '@svgdotjs/svg.js';
5
+
4
6
  export interface GraphPoint {
5
7
  readonly x: number;
6
8
  readonly y: number;
7
9
  }
8
10
  export interface Node {
11
+ readonly color?: string;
9
12
  readonly id: string;
10
13
  readonly title: string;
11
- readonly color?: string;
12
14
  }
13
15
  export interface Edge {
14
16
  readonly source: string;
@@ -16,20 +18,17 @@ export interface Edge {
16
18
  readonly type: string;
17
19
  readonly value: number;
18
20
  }
19
- export interface Graph {
20
- readonly nodes: Node[];
21
+ export interface GraphData {
21
22
  readonly edges: Edge[];
23
+ readonly nodes: Node[];
22
24
  readonly options: SankeyOptions;
23
25
  }
24
26
  export declare class SankeyGraph extends Paper {
25
- graph: any;
27
+ graph: Graph;
26
28
  maxRank: number;
27
- element: HTMLElement;
28
- options: SankeyOptions;
29
- constructor(element: HTMLElement, options: SankeyOptions);
30
- construct(data: Graph): void;
31
- renderEdge(edgeObj: any, group: G): void;
29
+ construct(data: GraphData): void;
32
30
  render({ keepOldPosition }?: {
33
31
  keepOldPosition?: boolean;
34
32
  }): void;
33
+ renderEdge(edgeObj: any, group: G): void;
35
34
  }
@@ -1,3 +1,4 @@
1
- import { G } from '@svgdotjs/svg.js';
2
1
  import { FontOptions, NodeOptions } from './Options';
3
- export declare function renderNode(graphNode: any, maxRank: number, options: Partial<NodeOptions & FontOptions>): G;
2
+ import { G } from '@svgdotjs/svg.js';
3
+
4
+ export declare function renderNode(graphNode: any, maxRank: number, options: Partial<FontOptions & NodeOptions>): G;
@@ -1,31 +1,34 @@
1
1
  export interface CommonOptions {
2
- readonly width: number;
3
- readonly height: number;
4
2
  readonly canvasStyle: string;
3
+ readonly enableToolbar: boolean;
4
+ readonly height: number | string;
5
5
  readonly spacing: number;
6
+ readonly viewPortHeight: number;
7
+ readonly viewPortWidth: number;
8
+ readonly width: number | string;
6
9
  }
7
10
  export interface NodeOptions {
8
- readonly nodeWidth: number;
9
- readonly nodeBorderWidth: number;
10
11
  readonly nodeBorderColor: string;
12
+ readonly nodeBorderWidth: number;
13
+ readonly nodeWidth: number;
11
14
  readonly onNodeClick?: (node: any) => void;
12
15
  }
13
16
  export interface EdgeOptions {
14
- readonly edgeOpacity: number;
15
17
  readonly edgeGradientFill: boolean;
18
+ readonly edgeOpacity: number;
16
19
  }
17
20
  export interface FontOptions {
18
- readonly fontSize: string;
21
+ readonly fontColor: string;
19
22
  readonly fontFamily: string;
23
+ readonly fontSize: string;
20
24
  readonly fontWeight: number;
21
- readonly fontColor: string;
22
25
  }
23
26
  export interface TooltipOptions {
24
27
  readonly enableTooltip: boolean;
25
- readonly tooltipId: string;
26
- readonly tooltipTemplate?: (content: any) => any;
27
- readonly tooltipBorderColor: string;
28
28
  readonly tooltipBGColor: string;
29
+ readonly tooltipBorderColor: string;
30
+ readonly tooltipId: string;
31
+ readonly tooltipTemplate?: (content: any) => string;
29
32
  }
30
- export type SankeyOptions = CommonOptions & NodeOptions & TooltipOptions & EdgeOptions & FontOptions;
33
+ export type SankeyOptions = CommonOptions & EdgeOptions & FontOptions & NodeOptions & TooltipOptions;
31
34
  export declare const DefaultOptions: SankeyOptions;
@@ -1,13 +1,18 @@
1
+ import { SankeyOptions } from './Options';
1
2
  import { Element, Svg } from '@svgdotjs/svg.js';
3
+
2
4
  export declare class Paper {
3
- private readonly width;
4
- private readonly height;
5
- private readonly spacing;
5
+ element: HTMLElement;
6
+ options: SankeyOptions;
6
7
  canvas: Svg;
7
- constructor(element: HTMLElement, width: number, height: number, canvasStyle: string, spacing: number);
8
+ constructor(element: HTMLElement, options: SankeyOptions);
9
+ private getYShift;
8
10
  add(element: Element): void;
11
+ clear(): void;
9
12
  resetViewBox(): void;
10
13
  updateViewBox(x: number, y: number, width: number, height: number): void;
11
14
  zoom(zoomFactor: number): void;
12
- clear(): void;
15
+ get height(): number;
16
+ get spacing(): number;
17
+ get width(): number;
13
18
  }
package/lib/sankey.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { SankeyGraph, Graph } from './models/Graph';
2
1
  import { SankeyOptions } from './models/Options';
2
+ import { GraphData, SankeyGraph } from './models/Graph';
3
+
3
4
  export declare class ApexSankey {
4
5
  element: HTMLElement;
5
- graph: SankeyGraph;
6
6
  options: SankeyOptions;
7
+ graph: SankeyGraph;
7
8
  constructor(element: HTMLElement, options: SankeyOptions);
8
- render(data: Graph): SankeyGraph;
9
+ render(data: GraphData): SankeyGraph;
9
10
  }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "apexsankey",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "dependencies": {
5
+ "@apex/graph-utils": "*",
5
6
  "@svgdotjs/svg.js": "^3.2.0",
6
7
  "@svgdotjs/svg.panzoom.js": "^2.1.2",
7
8
  "defined": "^1.0.1",
@@ -1,5 +0,0 @@
1
- export declare const getTooltip: (tooltipId?: string) => HTMLElement;
2
- export declare const updateTooltip: (id?: string, styles?: string | undefined, content?: string) => void;
3
- export declare const getTooltipStyles: (x: number, y: number, borderColor: string, bgColor: string) => ReadonlyArray<string>;
4
- export declare const generateStyles: (styleObject?: Record<string, number | string>) => string;
5
- export declare const camelToKebabCase: (str: string) => string;
@@ -1,37 +0,0 @@
1
- import { CircleAttr } from '@svgdotjs/svg.js';
2
- import { Text } from '@svgdotjs/svg.js';
3
- import { Path } from '@svgdotjs/svg.js';
4
- import { Gradient } from '@svgdotjs/svg.js';
5
- import { G } from '@svgdotjs/svg.js';
6
- import { Line } from '@svgdotjs/svg.js';
7
- import { ForeignObject } from '@svgdotjs/svg.js';
8
- import { Circle } from '@svgdotjs/svg.js';
9
- import { Rect } from '@svgdotjs/svg.js';
10
- export declare function drawRect({ x, y, width, height, radius, color, borderColor, opacity, }?: {
11
- x?: number;
12
- y?: number;
13
- width?: number;
14
- height?: number;
15
- radius?: number;
16
- color?: string;
17
- borderColor?: string;
18
- opacity?: number;
19
- }): Rect;
20
- export declare function drawCircle(attributes?: CircleAttr): Circle;
21
- export declare function drawText(text: string, { x, y, fontColor, textAnchor, pointerEvents }: any): Text;
22
- export declare function drawTemplate(template: string, { nodeWidth, nodeHeight }?: any): ForeignObject;
23
- export declare function drawGroup(x?: number, y?: number, id?: string, parent?: string): G;
24
- export declare function drawPath(pathString: string, { id, edgeColor, opacity }?: Partial<{
25
- readonly id: string;
26
- readonly edgeColor: Gradient;
27
- readonly opacity: number;
28
- }>): Path;
29
- export declare function drawLine({ className, x1, x2, y1, y2, borderSize, borderColor, }?: {
30
- className?: string;
31
- x1?: number;
32
- x2?: number;
33
- y1?: number;
34
- y2?: number;
35
- borderSize?: number;
36
- borderColor?: string;
37
- }): Line;