@hpcc-js/graph 2.84.4 → 2.85.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/graph",
3
- "version": "2.84.4",
3
+ "version": "2.85.1",
4
4
  "description": "hpcc-js - Viz Graph",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es6",
@@ -88,5 +88,5 @@
88
88
  "url": "https://github.com/hpcc-systems/Visualization/issues"
89
89
  },
90
90
  "homepage": "https://github.com/hpcc-systems/Visualization",
91
- "gitHead": "cec45fe4a28dff27d43cf0bb9238d751534c8e88"
91
+ "gitHead": "c1baf3e4992b882bbe526b550a72b873f0f4ccc2"
92
92
  }
@@ -1,3 +1,3 @@
1
1
  export const PKG_NAME = "@hpcc-js/graph";
2
- export const PKG_VERSION = "2.84.4";
3
- export const BUILD_VERSION = "2.104.14";
2
+ export const PKG_VERSION = "2.85.1";
3
+ export const BUILD_VERSION = "2.104.16";
@@ -219,7 +219,7 @@ export class GraphT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E e
219
219
  resolveEventOrigin(): { origin: string, data?: SG | V | E } {
220
220
  const d3evt = d3Event();
221
221
  const eventPath = d3evt?.sourceEvent?.path ?? d3evt?.path;
222
- const element = eventPath.find(n => n?.hasAttribute && n?.hasAttribute("data-click"));
222
+ const element = eventPath?.find(n => n?.hasAttribute && n?.hasAttribute("data-click"));
223
223
  const origin = element ? element.getAttribute("data-click") : "";
224
224
  const dataStr = element ? element.getAttribute("data-click-data") : "";
225
225
  let data = undefined;
@@ -1,5 +1,5 @@
1
1
  import { curveBasis as d3CurveBasis, line as d3Line } from "d3-shape";
2
- import { Cluster, graphviz as gvWorker, Node } from "./graphvizWorker";
2
+ import { Cluster, graphviz as gvWorker, Node, isLayoutSuccess, LayoutError } from "./graphvizWorker";
3
3
  import { Layout, Point } from "./layout";
4
4
  import { EdgePlaceholder } from "./placeholders";
5
5
 
@@ -60,31 +60,39 @@ export class Graphviz extends Layout {
60
60
  raw: ""
61
61
  }, {
62
62
  engine: this._engine
63
- }).response.then((response: any) => {
63
+ }).response.then(response => {
64
64
  if (this.running()) {
65
- response.clusters.forEach(n => {
66
- const sg = data.subgraph(n.id);
67
- sg.x = n.x + size.width / 2 - n.width;
68
- sg.y = n.y + size.height / 2 - n.height;
69
- sg.props.width = n.width;
70
- sg.props.height = n.height;
71
- });
72
- response.nodes.forEach(n => {
73
- const v = data.vertex(n.id);
74
- v.x = n.x + size.width / 2;
75
- v.y = n.y + size.height / 2;
76
- });
77
- response.links.forEach(l => {
78
- const e = data.edge(l.id);
79
- e.points = [[e.source.x, e.source.y], ...(l.points !== undefined ? l.points.map(p => [p[0] + size.width / 2, p[1] + size.height / 2]) : []), [e.target.x, e.target.y]];
80
- // e.points = l.points.map(p => [p[0] + size.width / 2, p[1] + size.height / 2]);
81
- });
82
- this._graph
83
- .moveSubgraphs(true)
84
- .moveVertices(true)
85
- .moveEdges(true)
86
- ;
87
- this.stop();
65
+ if (isLayoutSuccess(response)) {
66
+ response.clusters.forEach(n => {
67
+ const sg = data.subgraph(n.id);
68
+ sg.x = n.x + size.width / 2 - n.width;
69
+ sg.y = n.y + size.height / 2 - n.height;
70
+ sg.props.width = n.width;
71
+ sg.props.height = n.height;
72
+ });
73
+ response.nodes.forEach(n => {
74
+ const v = data.vertex(n.id);
75
+ v.x = n.x + size.width / 2;
76
+ v.y = n.y + size.height / 2;
77
+ });
78
+ response.links.forEach(l => {
79
+ const e = data.edge(l.id);
80
+ const start: [number, number] = [e.source.x, e.source.y];
81
+ const mid: [number, number][] = l.points !== undefined ? l.points.map(p => [p[0] + size.width / 2, p[1] + size.height / 2]) : [];
82
+ const end: [number, number] = [e.target.x, e.target.y];
83
+ e.points = [start, ...mid, end];
84
+ // e.points = l.points.map(p => [p[0] + size.width / 2, p[1] + size.height / 2]);
85
+ });
86
+ this._graph
87
+ .moveSubgraphs(true)
88
+ .moveVertices(true)
89
+ .moveEdges(true)
90
+ ;
91
+ this.stop();
92
+ } else {
93
+ const err = response as LayoutError;
94
+ console.error(`Graphviz layout fail: ${err.error}`, err.errorDot);
95
+ }
88
96
  }
89
97
  return this;
90
98
  });
@@ -1,4 +1,4 @@
1
1
  export declare const PKG_NAME = "@hpcc-js/graph";
2
- export declare const PKG_VERSION = "2.84.4";
3
- export declare const BUILD_VERSION = "2.104.14";
2
+ export declare const PKG_VERSION = "2.85.1";
3
+ export declare const BUILD_VERSION = "2.104.16";
4
4
  //# sourceMappingURL=__package__.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphviz.d.ts","sourceRoot":"","sources":["../../../src/graph2/layouts/graphviz.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,aAAK,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAC;AAQlF,qBAAa,QAAS,SAAQ,MAAM;IAEhC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBAER,KAAK,KAAA,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAMrD,KAAK;IAoEL,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAA;KAAE;CAsBvF"}
1
+ {"version":3,"file":"graphviz.d.ts","sourceRoot":"","sources":["../../../src/graph2/layouts/graphviz.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,aAAK,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAC;AAQlF,qBAAa,QAAS,SAAQ,MAAM;IAEhC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBAER,KAAK,KAAA,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAMrD,KAAK;IA4EL,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAA;KAAE;CAsBvF"}
@@ -32,6 +32,23 @@ export interface Data {
32
32
  export interface Options {
33
33
  engine: Engine;
34
34
  }
35
+ export interface LayoutError {
36
+ error?: string;
37
+ errorDot?: string;
38
+ }
39
+ export interface LayoutSVG extends LayoutError {
40
+ svg?: string;
41
+ }
42
+ export interface LayoutJSON extends LayoutError {
43
+ json?: any;
44
+ }
45
+ export declare type LayoutSuccess = {
46
+ clusters: Cluster[];
47
+ nodes: Node[];
48
+ links: Link[];
49
+ };
50
+ export declare type Layout = LayoutSuccess | LayoutJSON | LayoutSVG;
51
+ export declare function isLayoutSuccess(item: any): item is LayoutSuccess;
35
52
  export declare function graphviz(data: Data, options: Options): {
36
53
  terminate: () => void;
37
54
  response: Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"graphvizWorker.d.ts","sourceRoot":"","sources":["../../../src/graph2/layouts/graphvizWorker.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAC;AAEzF,MAAM,WAAW,OAAO;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAGhC,CAAC,CAAC,EAAE,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QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,EAAE,IAAI,EAAE,CAAC;IAAC,KAAK,EAAE,IAAI,EAAE,CAAA;CAAE,CAAC;AAClF,oBAAY,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5D,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,aAAa,CAIhE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO;;;EAmBpD"}
@@ -1,4 +1,4 @@
1
1
  export declare const PKG_NAME = "@hpcc-js/graph";
2
- export declare const PKG_VERSION = "2.84.4";
3
- export declare const BUILD_VERSION = "2.104.14";
2
+ export declare const PKG_VERSION = "2.85.1";
3
+ export declare const BUILD_VERSION = "2.104.16";
4
4
  //# sourceMappingURL=__package__.d.ts.map
@@ -35,6 +35,23 @@ export interface Data {
35
35
  export interface Options {
36
36
  engine: Engine;
37
37
  }
38
+ export interface LayoutError {
39
+ error?: string;
40
+ errorDot?: string;
41
+ }
42
+ export interface LayoutSVG extends LayoutError {
43
+ svg?: string;
44
+ }
45
+ export interface LayoutJSON extends LayoutError {
46
+ json?: any;
47
+ }
48
+ export declare type LayoutSuccess = {
49
+ clusters: Cluster[];
50
+ nodes: Node[];
51
+ links: Link[];
52
+ };
53
+ export declare type Layout = LayoutSuccess | LayoutJSON | LayoutSVG;
54
+ export declare function isLayoutSuccess(item: any): item is LayoutSuccess;
38
55
  export declare function graphviz(data: Data, options: Options): {
39
56
  terminate: () => void;
40
57
  response: Promise<string>;