@hpcc-js/graph 3.7.4 → 3.7.5

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 (77) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +256 -256
  3. package/dist/assets/dagre-B-z4SP0u.js.map +1 -1
  4. package/dist/assets/graphviz-BK7FEJlA.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.cjs +1 -1
  8. package/dist/index.umd.cjs.map +1 -1
  9. package/package.json +7 -7
  10. package/src/AdjacencyGraph.ts +224 -224
  11. package/src/Edge.css +22 -22
  12. package/src/Edge.ts +257 -257
  13. package/src/Graph.css +18 -18
  14. package/src/Graph.ts +1077 -1077
  15. package/src/GraphData.ts +187 -187
  16. package/src/GraphLayouts.ts +214 -214
  17. package/src/Sankey.css +44 -44
  18. package/src/Sankey.ts +304 -304
  19. package/src/Subgraph.css +9 -9
  20. package/src/Subgraph.ts +165 -165
  21. package/src/Vertex.css +2 -2
  22. package/src/Vertex.ts +282 -282
  23. package/src/__package__.ts +3 -3
  24. package/src/__tests__/data.ts +444 -444
  25. package/src/__tests__/index.ts +1 -1
  26. package/src/__tests__/test1.ts +18 -18
  27. package/src/__tests__/test2.ts +80 -80
  28. package/src/__tests__/test3.ts +46 -46
  29. package/src/__tests__/test4.ts +66 -66
  30. package/src/__tests__/test5.ts +85 -85
  31. package/src/common/graphT.css +38 -38
  32. package/src/common/graphT.ts +1363 -1363
  33. package/src/common/index.ts +3 -3
  34. package/src/common/layouts/circle.ts +37 -37
  35. package/src/common/layouts/dagre.ts +145 -145
  36. package/src/common/layouts/dagreWorker.ts +24 -24
  37. package/src/common/layouts/forceDirected.ts +117 -117
  38. package/src/common/layouts/forceDirectedWorker.ts +22 -22
  39. package/src/common/layouts/geoForceDirected.ts +112 -112
  40. package/src/common/layouts/graphviz.ts +137 -137
  41. package/src/common/layouts/graphvizWorker.ts +27 -27
  42. package/src/common/layouts/index.ts +7 -7
  43. package/src/common/layouts/layout.ts +147 -147
  44. package/src/common/layouts/null.ts +39 -39
  45. package/src/common/layouts/placeholders.ts +113 -113
  46. package/src/common/layouts/tree.ts +326 -326
  47. package/src/common/layouts/workers/dagre.ts +46 -46
  48. package/src/common/layouts/workers/dagreOptions.ts +35 -35
  49. package/src/common/layouts/workers/forceDirected.ts +38 -38
  50. package/src/common/layouts/workers/forceDirectedOptions.ts +30 -30
  51. package/src/common/layouts/workers/graphviz.ts +225 -225
  52. package/src/common/layouts/workers/graphvizOptions.ts +70 -70
  53. package/src/common/liteMap.ts +72 -72
  54. package/src/common/liteSVGZooom.ts +61 -61
  55. package/src/common/sankeyGraph.css +44 -44
  56. package/src/common/sankeyGraph.ts +345 -345
  57. package/src/html/annotation.ts +71 -71
  58. package/src/html/component.ts +18 -18
  59. package/src/html/edge.ts +15 -15
  60. package/src/html/graphHtml.ts +11 -11
  61. package/src/html/graphHtmlT.ts +117 -117
  62. package/src/html/icon.ts +64 -64
  63. package/src/html/image.ts +26 -26
  64. package/src/html/imageChar.ts +18 -18
  65. package/src/html/index.ts +8 -8
  66. package/src/html/intersection.ts +110 -110
  67. package/src/html/shape.ts +141 -141
  68. package/src/html/text.ts +59 -59
  69. package/src/html/textBox.ts +45 -45
  70. package/src/html/vertex.ts +67 -67
  71. package/src/index.ts +10 -10
  72. package/src/react/dataGraph.ts +345 -345
  73. package/src/react/graphReact.ts +177 -177
  74. package/src/react/graphReactT.ts +44 -44
  75. package/src/react/index.ts +4 -4
  76. package/src/react/subgraph.tsx +30 -30
  77. package/src/react/vertex.tsx +31 -31
@@ -1,71 +1,71 @@
1
- import { svg } from "lit-html";
2
- import { Palette, Utility } from "@hpcc-js/common";
3
- import { extend } from "./component.ts";
4
- import { TextBox } from "./textBox.ts";
5
-
6
- export interface AnnotationProps {
7
- text: string;
8
- fontFamily?: string;
9
- fontSize?: number;
10
- fill?: string;
11
- stroke?: string;
12
- }
13
-
14
- export const annotation = ({
15
- text,
16
- fontFamily = "FontAwesome",
17
- fontSize = 8,
18
- fill = "gray",
19
- stroke = "darkgray"
20
- }: AnnotationProps) => {
21
- const renderChar = fontFamily === "FontAwesome" ? Utility.faChar(text) : text;
22
- const textBoxTpl = TextBox({
23
- text: {
24
- text: renderChar,
25
- fill: Palette.textColor(fill),
26
- fontFamily,
27
- fontSize,
28
- dominantBaseline: fontFamily === "FontAwesome" ? "ideographic" : undefined
29
- },
30
- padding: 3,
31
- fill,
32
- stroke,
33
- cornerRadius: 0
34
- });
35
- return extend(svg`\
36
- <g data-click="annotation" data-click-data=${JSON.stringify({ text, fill, fontFamily, fontSize, stroke })}>
37
- ${textBoxTpl}
38
- </g>`, textBoxTpl.extent.width, textBoxTpl.extent.height);
39
- };
40
-
41
- export interface AnnotationsProps {
42
- annotations: AnnotationProps[];
43
- padding?: number;
44
- }
45
-
46
- export const annotations = ({
47
- annotations,
48
- padding = 3,
49
- }: AnnotationsProps) => {
50
- let xOffset = 0;
51
- const items = annotations.map(annotationProp => {
52
- const ann = annotation(annotationProp);
53
- const itemSvg = extend(svg`\
54
- <g transform="translate(${xOffset + ann.extent.width / 2} 0)">
55
- ${ann}
56
- </g>`, ann.extent.width, ann.extent.height);
57
- xOffset += ann.extent.width + padding;
58
- return itemSvg;
59
- });
60
- const { width, height } = items.reduce((acc, item) => {
61
- return {
62
- width: acc.width + item.extent.width,
63
- height: Math.max(acc.height, item.extent.height)
64
- };
65
- }, { width: (items.length - 1) * padding, height: 0 });
66
- return extend(svg`\
67
- <g transform="translate(${-width / 2} 0)">
68
- ${items}
69
- </g>`, width, height);
70
- };
71
-
1
+ import { svg } from "lit-html";
2
+ import { Palette, Utility } from "@hpcc-js/common";
3
+ import { extend } from "./component.ts";
4
+ import { TextBox } from "./textBox.ts";
5
+
6
+ export interface AnnotationProps {
7
+ text: string;
8
+ fontFamily?: string;
9
+ fontSize?: number;
10
+ fill?: string;
11
+ stroke?: string;
12
+ }
13
+
14
+ export const annotation = ({
15
+ text,
16
+ fontFamily = "FontAwesome",
17
+ fontSize = 8,
18
+ fill = "gray",
19
+ stroke = "darkgray"
20
+ }: AnnotationProps) => {
21
+ const renderChar = fontFamily === "FontAwesome" ? Utility.faChar(text) : text;
22
+ const textBoxTpl = TextBox({
23
+ text: {
24
+ text: renderChar,
25
+ fill: Palette.textColor(fill),
26
+ fontFamily,
27
+ fontSize,
28
+ dominantBaseline: fontFamily === "FontAwesome" ? "ideographic" : undefined
29
+ },
30
+ padding: 3,
31
+ fill,
32
+ stroke,
33
+ cornerRadius: 0
34
+ });
35
+ return extend(svg`\
36
+ <g data-click="annotation" data-click-data=${JSON.stringify({ text, fill, fontFamily, fontSize, stroke })}>
37
+ ${textBoxTpl}
38
+ </g>`, textBoxTpl.extent.width, textBoxTpl.extent.height);
39
+ };
40
+
41
+ export interface AnnotationsProps {
42
+ annotations: AnnotationProps[];
43
+ padding?: number;
44
+ }
45
+
46
+ export const annotations = ({
47
+ annotations,
48
+ padding = 3,
49
+ }: AnnotationsProps) => {
50
+ let xOffset = 0;
51
+ const items = annotations.map(annotationProp => {
52
+ const ann = annotation(annotationProp);
53
+ const itemSvg = extend(svg`\
54
+ <g transform="translate(${xOffset + ann.extent.width / 2} 0)">
55
+ ${ann}
56
+ </g>`, ann.extent.width, ann.extent.height);
57
+ xOffset += ann.extent.width + padding;
58
+ return itemSvg;
59
+ });
60
+ const { width, height } = items.reduce((acc, item) => {
61
+ return {
62
+ width: acc.width + item.extent.width,
63
+ height: Math.max(acc.height, item.extent.height)
64
+ };
65
+ }, { width: (items.length - 1) * padding, height: 0 });
66
+ return extend(svg`\
67
+ <g transform="translate(${-width / 2} 0)">
68
+ ${items}
69
+ </g>`, width, height);
70
+ };
71
+
@@ -1,18 +1,18 @@
1
- import type { HTMLTemplateResult, SVGTemplateResult } from "lit-html";
2
- import type { Pos, Segment, Extent } from "./intersection.ts";
3
-
4
- export type TemplateResult = HTMLTemplateResult | SVGTemplateResult;
5
- export type IntersectionFunc = (pos: Pos, line: Segment) => Pos | null;
6
- export type TemplateResultEx = TemplateResult & {
7
- extent?: Extent;
8
- intersection: IntersectionFunc;
9
- };
10
- export function extend(result: TemplateResult, width: number, height: number, intersection: IntersectionFunc = (pos: Pos, line: Segment) => null): TemplateResultEx {
11
- return {
12
- ...result,
13
- extent: { width, height },
14
- intersection
15
- };
16
- }
17
- export type Component<T> = (props: T) => TemplateResult;
18
-
1
+ import type { HTMLTemplateResult, SVGTemplateResult } from "lit-html";
2
+ import type { Pos, Segment, Extent } from "./intersection.ts";
3
+
4
+ export type TemplateResult = HTMLTemplateResult | SVGTemplateResult;
5
+ export type IntersectionFunc = (pos: Pos, line: Segment) => Pos | null;
6
+ export type TemplateResultEx = TemplateResult & {
7
+ extent?: Extent;
8
+ intersection: IntersectionFunc;
9
+ };
10
+ export function extend(result: TemplateResult, width: number, height: number, intersection: IntersectionFunc = (pos: Pos, line: Segment) => null): TemplateResultEx {
11
+ return {
12
+ ...result,
13
+ extent: { width, height },
14
+ intersection
15
+ };
16
+ }
17
+ export type Component<T> = (props: T) => TemplateResult;
18
+
package/src/html/edge.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { svg } from "lit-html";
2
- import type { SubgraphBaseProps, EdgeBaseProps, VertexBaseProps } from "../common/layouts/placeholders.ts";
3
- import { GraphHtmlT } from "./graphHtmlT.ts";
4
-
5
- export interface EdgeProps<V extends VertexBaseProps> extends EdgeBaseProps<V> {
6
- graphInstance: GraphHtmlT<SubgraphBaseProps, V, EdgeProps<V>>;
7
- }
8
-
9
- export const edge = ({
10
- graphInstance,
11
- strokeWidth,
12
- path
13
- }: EdgeProps<VertexBaseProps>) => {
14
- return svg`<path d="${path}" marker-start="url(#${graphInstance.id()}_source${graphInstance.sourceMarker()})" marker-end="url(#${graphInstance.id()}_target${graphInstance.targetMarker()})" style="stroke-width:${strokeWidth}px"></path>`;
15
- };
1
+ import { svg } from "lit-html";
2
+ import type { SubgraphBaseProps, EdgeBaseProps, VertexBaseProps } from "../common/layouts/placeholders.ts";
3
+ import { GraphHtmlT } from "./graphHtmlT.ts";
4
+
5
+ export interface EdgeProps<V extends VertexBaseProps> extends EdgeBaseProps<V> {
6
+ graphInstance: GraphHtmlT<SubgraphBaseProps, V, EdgeProps<V>>;
7
+ }
8
+
9
+ export const edge = ({
10
+ graphInstance,
11
+ strokeWidth,
12
+ path
13
+ }: EdgeProps<VertexBaseProps>) => {
14
+ return svg`<path d="${path}" marker-start="url(#${graphInstance.id()}_source${graphInstance.sourceMarker()})" marker-end="url(#${graphInstance.id()}_target${graphInstance.targetMarker()})" style="stroke-width:${strokeWidth}px"></path>`;
15
+ };
@@ -1,11 +1,11 @@
1
- import { GraphHtmlT, SubgraphBaseProps, EdgeBaseProps } from "./graphHtmlT.ts";
2
- import { vertex, VertexProps } from "./vertex.ts";
3
- import { edge, EdgeProps } from "./edge.ts";
4
-
5
- export class GraphHtml extends GraphHtmlT<SubgraphBaseProps, VertexProps, EdgeProps<VertexProps>> {
6
- constructor() {
7
- super(undefined, vertex, edge);
8
- }
9
-
10
- }
11
- GraphHtml.prototype._class += " graph_GraphHtml";
1
+ import { GraphHtmlT, SubgraphBaseProps, EdgeBaseProps } from "./graphHtmlT.ts";
2
+ import { vertex, VertexProps } from "./vertex.ts";
3
+ import { edge, EdgeProps } from "./edge.ts";
4
+
5
+ export class GraphHtml extends GraphHtmlT<SubgraphBaseProps, VertexProps, EdgeProps<VertexProps>> {
6
+ constructor() {
7
+ super(undefined, vertex, edge);
8
+ }
9
+
10
+ }
11
+ GraphHtml.prototype._class += " graph_GraphHtml";
@@ -1,117 +1,117 @@
1
- import { html, svg, render } from "lit-html";
2
- import type { BaseProps, EdgeBaseProps, SubgraphBaseProps, VertexBaseProps } from "../common/graphT.ts";
3
- import { GraphT, RendererT } from "../common/graphT.ts";
4
- import type { Component } from "./component.ts";
5
- import { TextBox } from "./textBox.ts";
6
- import { icon } from "./icon.ts";
7
-
8
- export { html, svg, EdgeBaseProps, SubgraphBaseProps, VertexBaseProps };
9
-
10
- export function adapter<T extends BaseProps>(component: Component<T>): RendererT<T> {
11
- return (props: T, element: SVGGElement) => {
12
- const componentTpl = component(props);
13
- render(componentTpl, element as any);
14
- return componentTpl;
15
- };
16
- }
17
-
18
- const defaultSubgraphRenderer = ({
19
- text = "",
20
- }: SubgraphBaseProps) => {
21
- return svg`<text font-family="monospace" font-size="10px" text-anchor="middle" dominant-baseline="middle" fill="black">${text}</text>`;
22
- };
23
-
24
- const defaultVertexRenderer = ({
25
- text
26
- }: VertexBaseProps) => {
27
-
28
- return svg`\
29
- ${icon({ imageChar: "" })}
30
- ${TextBox({ text: { text } })}
31
- `;
32
- };
33
-
34
- const defaultEdgeRenderer = ({
35
- strokeWidth,
36
- path
37
- }: EdgeBaseProps<VertexBaseProps>) => {
38
- return svg`<path d="${path}" style="stroke-width:${strokeWidth}px"></path>`;
39
- };
40
-
41
- export class GraphHtmlT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> extends GraphT<SG, V, E> {
42
-
43
- constructor(subgraphRenderer: Component<SG> = defaultSubgraphRenderer, vertexRenderer: Component<V> = defaultVertexRenderer, edgeRenderer: Component<E> = defaultEdgeRenderer) {
44
- super(adapter(subgraphRenderer), adapter<V>(vertexRenderer), adapter(edgeRenderer));
45
- }
46
-
47
- enterMarkers(clearFirst: boolean = false) {
48
- if (clearFirst) {
49
- this._svgDefs.select("#" + this._id + "_sourceDot").remove();
50
- this._svgDefs.select("#" + this._id + "_targetDot").remove();
51
- this._svgDefs.select("#" + this._id + "_targetArrow").remove();
52
- }
53
- this._svgDefs.append("marker")
54
- .attr("class", "marker")
55
- .attr("id", this._id + "_sourceDot")
56
- .attr("refX", 1)
57
- .attr("refY", 3)
58
- .attr("markerWidth", 6)
59
- .attr("markerHeight", 6)
60
- .attr("markerUnits", "strokeWidth")
61
- .attr("orient", "auto")
62
- .append("circle")
63
- .attr("cx", 3)
64
- .attr("cy", 3)
65
- .attr("r", 1.5)
66
- .attr("fill", "context-stroke")
67
- .attr("stroke", "context-stroke")
68
- ;
69
- this._svgDefs.append("marker")
70
- .attr("class", "marker")
71
- .attr("id", this._id + "_targetDot")
72
- .attr("refX", 5)
73
- .attr("refY", 3)
74
- .attr("markerWidth", 6)
75
- .attr("markerHeight", 6)
76
- .attr("markerUnits", "strokeWidth")
77
- .attr("orient", "auto")
78
- .append("circle")
79
- .attr("cx", 3)
80
- .attr("cy", 3)
81
- .attr("r", 1.5)
82
- .attr("fill", "context-stroke")
83
- .attr("stroke", "context-stroke")
84
- ;
85
- this._svgDefs.append("marker")
86
- .attr("class", "marker")
87
- .attr("id", this._id + "_targetArrow")
88
- .attr("viewBox", "0 0 10 10")
89
- .attr("refX", 10)
90
- .attr("refY", 5)
91
- .attr("markerWidth", 5)
92
- .attr("markerHeight", 5)
93
- .attr("markerUnits", "strokeWidth")
94
- .attr("orient", "auto")
95
- .append("polyline")
96
- .attr("points", "0,0 10,5 0,10 0,5")
97
- .attr("fill", "context-stroke")
98
- .attr("stroke", "context-stroke")
99
- ;
100
- }
101
-
102
- enter(domNode, element) {
103
- super.enter(domNode, element);
104
- this.enterMarkers();
105
- }
106
- }
107
- GraphHtmlT.prototype._class += " graph_GraphHtmlT";
108
-
109
- export interface GraphHtmlT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> extends GraphT<SG, V, E> {
110
- sourceMarker(): "Dot" | "None";
111
- sourceMarker(_: "Dot" | "None"): this;
112
- targetMarker(): "Arrow" | "Dot" | "None";
113
- targetMarker(_: "Arrow" | "Dot" | "None"): this;
114
- }
115
-
116
- GraphHtmlT.prototype.publish("sourceMarker", "Dot", "set", "Target Marker", ["Dot", "None"]);
117
- GraphHtmlT.prototype.publish("targetMarker", "Arrow", "set", "Target Marker", ["Arrow", "Dot", "None"]);
1
+ import { html, svg, render } from "lit-html";
2
+ import type { BaseProps, EdgeBaseProps, SubgraphBaseProps, VertexBaseProps } from "../common/graphT.ts";
3
+ import { GraphT, RendererT } from "../common/graphT.ts";
4
+ import type { Component } from "./component.ts";
5
+ import { TextBox } from "./textBox.ts";
6
+ import { icon } from "./icon.ts";
7
+
8
+ export { html, svg, EdgeBaseProps, SubgraphBaseProps, VertexBaseProps };
9
+
10
+ export function adapter<T extends BaseProps>(component: Component<T>): RendererT<T> {
11
+ return (props: T, element: SVGGElement) => {
12
+ const componentTpl = component(props);
13
+ render(componentTpl, element as any);
14
+ return componentTpl;
15
+ };
16
+ }
17
+
18
+ const defaultSubgraphRenderer = ({
19
+ text = "",
20
+ }: SubgraphBaseProps) => {
21
+ return svg`<text font-family="monospace" font-size="10px" text-anchor="middle" dominant-baseline="middle" fill="black">${text}</text>`;
22
+ };
23
+
24
+ const defaultVertexRenderer = ({
25
+ text
26
+ }: VertexBaseProps) => {
27
+
28
+ return svg`\
29
+ ${icon({ imageChar: "" })}
30
+ ${TextBox({ text: { text } })}
31
+ `;
32
+ };
33
+
34
+ const defaultEdgeRenderer = ({
35
+ strokeWidth,
36
+ path
37
+ }: EdgeBaseProps<VertexBaseProps>) => {
38
+ return svg`<path d="${path}" style="stroke-width:${strokeWidth}px"></path>`;
39
+ };
40
+
41
+ export class GraphHtmlT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> extends GraphT<SG, V, E> {
42
+
43
+ constructor(subgraphRenderer: Component<SG> = defaultSubgraphRenderer, vertexRenderer: Component<V> = defaultVertexRenderer, edgeRenderer: Component<E> = defaultEdgeRenderer) {
44
+ super(adapter(subgraphRenderer), adapter<V>(vertexRenderer), adapter(edgeRenderer));
45
+ }
46
+
47
+ enterMarkers(clearFirst: boolean = false) {
48
+ if (clearFirst) {
49
+ this._svgDefs.select("#" + this._id + "_sourceDot").remove();
50
+ this._svgDefs.select("#" + this._id + "_targetDot").remove();
51
+ this._svgDefs.select("#" + this._id + "_targetArrow").remove();
52
+ }
53
+ this._svgDefs.append("marker")
54
+ .attr("class", "marker")
55
+ .attr("id", this._id + "_sourceDot")
56
+ .attr("refX", 1)
57
+ .attr("refY", 3)
58
+ .attr("markerWidth", 6)
59
+ .attr("markerHeight", 6)
60
+ .attr("markerUnits", "strokeWidth")
61
+ .attr("orient", "auto")
62
+ .append("circle")
63
+ .attr("cx", 3)
64
+ .attr("cy", 3)
65
+ .attr("r", 1.5)
66
+ .attr("fill", "context-stroke")
67
+ .attr("stroke", "context-stroke")
68
+ ;
69
+ this._svgDefs.append("marker")
70
+ .attr("class", "marker")
71
+ .attr("id", this._id + "_targetDot")
72
+ .attr("refX", 5)
73
+ .attr("refY", 3)
74
+ .attr("markerWidth", 6)
75
+ .attr("markerHeight", 6)
76
+ .attr("markerUnits", "strokeWidth")
77
+ .attr("orient", "auto")
78
+ .append("circle")
79
+ .attr("cx", 3)
80
+ .attr("cy", 3)
81
+ .attr("r", 1.5)
82
+ .attr("fill", "context-stroke")
83
+ .attr("stroke", "context-stroke")
84
+ ;
85
+ this._svgDefs.append("marker")
86
+ .attr("class", "marker")
87
+ .attr("id", this._id + "_targetArrow")
88
+ .attr("viewBox", "0 0 10 10")
89
+ .attr("refX", 10)
90
+ .attr("refY", 5)
91
+ .attr("markerWidth", 5)
92
+ .attr("markerHeight", 5)
93
+ .attr("markerUnits", "strokeWidth")
94
+ .attr("orient", "auto")
95
+ .append("polyline")
96
+ .attr("points", "0,0 10,5 0,10 0,5")
97
+ .attr("fill", "context-stroke")
98
+ .attr("stroke", "context-stroke")
99
+ ;
100
+ }
101
+
102
+ enter(domNode, element) {
103
+ super.enter(domNode, element);
104
+ this.enterMarkers();
105
+ }
106
+ }
107
+ GraphHtmlT.prototype._class += " graph_GraphHtmlT";
108
+
109
+ export interface GraphHtmlT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> extends GraphT<SG, V, E> {
110
+ sourceMarker(): "Dot" | "None";
111
+ sourceMarker(_: "Dot" | "None"): this;
112
+ targetMarker(): "Arrow" | "Dot" | "None";
113
+ targetMarker(_: "Arrow" | "Dot" | "None"): this;
114
+ }
115
+
116
+ GraphHtmlT.prototype.publish("sourceMarker", "Dot", "set", "Target Marker", ["Dot", "None"]);
117
+ GraphHtmlT.prototype.publish("targetMarker", "Arrow", "set", "Target Marker", ["Arrow", "Dot", "None"]);
package/src/html/icon.ts CHANGED
@@ -1,64 +1,64 @@
1
- import { svg } from "lit-html";
2
- import { Palette } from "@hpcc-js/common";
3
- import { Image } from "./image.ts";
4
- import { ImageChar } from "./imageChar.ts";
5
- import { shape as litShape } from "./shape.ts";
6
- import { extend } from "./component.ts";
7
-
8
- export interface IconProps {
9
- shape?: "circle" | "square" | "rectangle";
10
- width?: number;
11
- height?: number;
12
- padding?: number;
13
- fill?: string;
14
- stroke?: string;
15
- strokeWidth?: number;
16
- imageUrl?: string;
17
- imageFontFamily?: string;
18
- imageChar?: string;
19
- imageCharFill?: string;
20
- cornerRadius?: number;
21
- }
22
-
23
- export function icon({
24
- shape = "circle",
25
- width,
26
- height = 32,
27
- fill = "transparent",
28
- stroke = fill !== "transparent" ? "black" : undefined,
29
- strokeWidth = stroke === undefined ? 0 : 1,
30
- imageUrl = "",
31
- imageFontFamily = "FontAwesome",
32
- imageChar = "",
33
- imageCharFill = Palette.textColor(fill),
34
- padding = height / 5,
35
- cornerRadius,
36
- }: IconProps) {
37
- const shapeTpl = litShape({
38
- shape,
39
- width,
40
- height,
41
- fill,
42
- stroke,
43
- strokeWidth,
44
- cornerRadius
45
- });
46
- const imageTpl = imageUrl ?
47
- Image({
48
- href: imageUrl,
49
- height: height - padding * 2
50
- }) :
51
- ImageChar({
52
- text: imageChar,
53
- fill: imageCharFill,
54
- fontFamily: imageFontFamily,
55
- fontSize: height - padding * 2,
56
- });
57
-
58
- return extend(svg`\
59
- <g>
60
- ${shapeTpl}
61
- ${imageTpl}
62
- </g>`, shapeTpl.extent.width, shapeTpl.extent.height, shapeTpl.intersection);
63
- };
64
-
1
+ import { svg } from "lit-html";
2
+ import { Palette } from "@hpcc-js/common";
3
+ import { Image } from "./image.ts";
4
+ import { ImageChar } from "./imageChar.ts";
5
+ import { shape as litShape } from "./shape.ts";
6
+ import { extend } from "./component.ts";
7
+
8
+ export interface IconProps {
9
+ shape?: "circle" | "square" | "rectangle";
10
+ width?: number;
11
+ height?: number;
12
+ padding?: number;
13
+ fill?: string;
14
+ stroke?: string;
15
+ strokeWidth?: number;
16
+ imageUrl?: string;
17
+ imageFontFamily?: string;
18
+ imageChar?: string;
19
+ imageCharFill?: string;
20
+ cornerRadius?: number;
21
+ }
22
+
23
+ export function icon({
24
+ shape = "circle",
25
+ width,
26
+ height = 32,
27
+ fill = "transparent",
28
+ stroke = fill !== "transparent" ? "black" : undefined,
29
+ strokeWidth = stroke === undefined ? 0 : 1,
30
+ imageUrl = "",
31
+ imageFontFamily = "FontAwesome",
32
+ imageChar = "",
33
+ imageCharFill = Palette.textColor(fill),
34
+ padding = height / 5,
35
+ cornerRadius,
36
+ }: IconProps) {
37
+ const shapeTpl = litShape({
38
+ shape,
39
+ width,
40
+ height,
41
+ fill,
42
+ stroke,
43
+ strokeWidth,
44
+ cornerRadius
45
+ });
46
+ const imageTpl = imageUrl ?
47
+ Image({
48
+ href: imageUrl,
49
+ height: height - padding * 2
50
+ }) :
51
+ ImageChar({
52
+ text: imageChar,
53
+ fill: imageCharFill,
54
+ fontFamily: imageFontFamily,
55
+ fontSize: height - padding * 2,
56
+ });
57
+
58
+ return extend(svg`\
59
+ <g>
60
+ ${shapeTpl}
61
+ ${imageTpl}
62
+ </g>`, shapeTpl.extent.width, shapeTpl.extent.height, shapeTpl.intersection);
63
+ };
64
+
package/src/html/image.ts CHANGED
@@ -1,26 +1,26 @@
1
- import { svg } from "lit-html";
2
- import { extend } from "./component.ts";
3
-
4
- export interface ImageProps {
5
- href: string;
6
- x?: number;
7
- y?: number;
8
- height?: number;
9
- yOffset?: number;
10
- }
11
-
12
- export const Image = ({
13
- href,
14
- x = 0,
15
- y = 0,
16
- height = 12
17
- }: ImageProps) => {
18
- return extend(svg`\
19
- <image
20
- xlink:href=${href}
21
- x=${x - height / 2}
22
- y=${y - height / 2}
23
- width=${height}
24
- height=${height}
25
- ></image>`, height, height);
26
- };
1
+ import { svg } from "lit-html";
2
+ import { extend } from "./component.ts";
3
+
4
+ export interface ImageProps {
5
+ href: string;
6
+ x?: number;
7
+ y?: number;
8
+ height?: number;
9
+ yOffset?: number;
10
+ }
11
+
12
+ export const Image = ({
13
+ href,
14
+ x = 0,
15
+ y = 0,
16
+ height = 12
17
+ }: ImageProps) => {
18
+ return extend(svg`\
19
+ <image
20
+ xlink:href=${href}
21
+ x=${x - height / 2}
22
+ y=${y - height / 2}
23
+ width=${height}
24
+ height=${height}
25
+ ></image>`, height, height);
26
+ };