@hpcc-js/react 3.4.9 → 3.4.10
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/LICENSE +43 -43
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/ImageChar.tsx +42 -42
- package/src/__package__.ts +3 -3
- package/src/edge.tsx +45 -45
- package/src/icon.tsx +95 -95
- package/src/image.tsx +25 -25
- package/src/index.ts +17 -17
- package/src/preact-shim.ts +4 -4
- package/src/render.ts +78 -78
- package/src/shape.tsx +138 -138
- package/src/span.tsx +9 -9
- package/src/subgraph.tsx +45 -45
- package/src/text.tsx +257 -257
- package/src/vertex.tsx +119 -119
- package/src/vertex2.tsx +100 -100
- package/src/vertex3.tsx +238 -238
- package/src/vertex4.tsx +308 -308
package/src/vertex4.tsx
CHANGED
|
@@ -1,308 +1,308 @@
|
|
|
1
|
-
import * as PReact from "./preact-shim.ts";
|
|
2
|
-
import { Utility } from "@hpcc-js/common";
|
|
3
|
-
import { Icon, IconProps } from "./icon.tsx";
|
|
4
|
-
import { TextBox, TextBoxProps } from "./text.tsx";
|
|
5
|
-
import { VertexProps } from "./vertex.tsx";
|
|
6
|
-
|
|
7
|
-
export interface IVertex4Annotation extends IconProps {
|
|
8
|
-
shapeOffsetX?: number;
|
|
9
|
-
shapeOffsetY?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IVertex4 extends VertexProps {
|
|
13
|
-
textboxStrokeWidth?: number;
|
|
14
|
-
annotations?: IVertex4Annotation[];
|
|
15
|
-
iconAnnotations?: IVertex4Annotation[];
|
|
16
|
-
annotationGutter?: number;
|
|
17
|
-
cornerRadius?: number;
|
|
18
|
-
subText?: any;
|
|
19
|
-
noLabelRadius?: number;
|
|
20
|
-
iconBorderWidth?: number;
|
|
21
|
-
iconBorderColor?: string;
|
|
22
|
-
iconBackgroundColor?: string;
|
|
23
|
-
shapeOffsetX?: number;
|
|
24
|
-
shapeOffsetY?: number;
|
|
25
|
-
iconOffsetX?: number;
|
|
26
|
-
iconOffsetY?: number;
|
|
27
|
-
iconPadding?: number;
|
|
28
|
-
iconFontSize?: number;
|
|
29
|
-
iconFontColor?: string;
|
|
30
|
-
iconFontFamily?: string;
|
|
31
|
-
iconText?: string;
|
|
32
|
-
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const Vertex4: PReact.FunctionComponent<IVertex4> = ({
|
|
36
|
-
categoryID = "",
|
|
37
|
-
text = "",
|
|
38
|
-
textHeight = 10,
|
|
39
|
-
textPadding = 4,
|
|
40
|
-
textFill = "#287EC4",
|
|
41
|
-
textboxFill = "white",
|
|
42
|
-
textboxStroke = "#CCCCCC",
|
|
43
|
-
textboxStrokeWidth = 1,
|
|
44
|
-
textFontFamily = "Verdana",
|
|
45
|
-
annotationGutter = 2,
|
|
46
|
-
annotations = [],
|
|
47
|
-
iconAnnotations = [],
|
|
48
|
-
cornerRadius = 3,
|
|
49
|
-
icon = {} as IconProps,
|
|
50
|
-
subText = {} as TextBoxProps,
|
|
51
|
-
showLabel = true,
|
|
52
|
-
noLabelRadius = 5,
|
|
53
|
-
|
|
54
|
-
iconBorderWidth = 1,
|
|
55
|
-
iconBorderColor = "#333",
|
|
56
|
-
|
|
57
|
-
iconBackgroundColor = "#fff",
|
|
58
|
-
|
|
59
|
-
iconFontColor = "#000",
|
|
60
|
-
iconFontSize = 20,
|
|
61
|
-
iconFontFamily = "FontAwesome",
|
|
62
|
-
|
|
63
|
-
shapeOffsetX = 0,
|
|
64
|
-
shapeOffsetY = 0,
|
|
65
|
-
iconOffsetX = 0,
|
|
66
|
-
iconOffsetY = 0,
|
|
67
|
-
|
|
68
|
-
iconPadding = 4,
|
|
69
|
-
iconText = "?",
|
|
70
|
-
shapeRendering = "auto"
|
|
71
|
-
}) => {
|
|
72
|
-
icon = {
|
|
73
|
-
height: 50,
|
|
74
|
-
imageChar: "?",
|
|
75
|
-
imageFontFamily: "FontAwesome",
|
|
76
|
-
imageCharFill: "#555555",
|
|
77
|
-
fill: "transparent",
|
|
78
|
-
strokeWidth: 0,
|
|
79
|
-
...icon
|
|
80
|
-
};
|
|
81
|
-
subText = {
|
|
82
|
-
text: "",
|
|
83
|
-
fill: "white",
|
|
84
|
-
textFill: "#555555",
|
|
85
|
-
...subText
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const annoOffsetY = 0;
|
|
89
|
-
const labelWidth = PReact.useMemo(() => {
|
|
90
|
-
return Utility.textSize(text, textFontFamily, textHeight, false).width;
|
|
91
|
-
}, [text, textFontFamily, textHeight]);
|
|
92
|
-
|
|
93
|
-
let labelShapeWidth = 0;
|
|
94
|
-
if (text !== "") {
|
|
95
|
-
labelShapeWidth = labelWidth + (textPadding * 2) + (textboxStrokeWidth * 2);
|
|
96
|
-
}
|
|
97
|
-
let fullAnnotationWidth = labelShapeWidth + annotationGutter;
|
|
98
|
-
const textOffsetX = fullAnnotationWidth - (labelShapeWidth / 2);
|
|
99
|
-
|
|
100
|
-
const textShapeHeight = textHeight + (annotationGutter * 2) + (textboxStrokeWidth * 2);
|
|
101
|
-
const annoWidthArr = annotations.map((anno) => {
|
|
102
|
-
return Utility.textSize(anno.imageChar, anno.imageFontFamily, anno.height, false).width;
|
|
103
|
-
});
|
|
104
|
-
const annotationArr = [];
|
|
105
|
-
let _labelAnnoOffsetX = fullAnnotationWidth;
|
|
106
|
-
annotations.forEach((anno, i) => {
|
|
107
|
-
const annoText = anno.imageChar;
|
|
108
|
-
const annoTextHeight = anno.height ?? textShapeHeight;
|
|
109
|
-
_labelAnnoOffsetX += annoWidthArr[i] + annotationGutter;
|
|
110
|
-
const annoOffsetX = _labelAnnoOffsetX - (annoWidthArr[i] / 2);
|
|
111
|
-
annotationArr.push(
|
|
112
|
-
<g key={i} className="vertex3-anno" data-click={"annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${annoOffsetX} ${annoOffsetY})`}>
|
|
113
|
-
<Icon
|
|
114
|
-
{...anno}
|
|
115
|
-
shape="rectangle"
|
|
116
|
-
width={annoWidthArr[i]}
|
|
117
|
-
height={annoTextHeight}
|
|
118
|
-
imageChar={annoText}
|
|
119
|
-
imageFontFamily={anno.imageFontFamily}
|
|
120
|
-
cornerRadius={cornerRadius}
|
|
121
|
-
strokeWidth={0}
|
|
122
|
-
/>
|
|
123
|
-
</g>
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
if (annotations.length > 0) {
|
|
128
|
-
fullAnnotationWidth += annotationGutter * (annotations.length - 1);
|
|
129
|
-
}
|
|
130
|
-
const iconAnnotationArr = [];
|
|
131
|
-
iconAnnotations.forEach((anno, i) => {
|
|
132
|
-
const x = anno.shapeOffsetX;
|
|
133
|
-
const y = anno.shapeOffsetY;
|
|
134
|
-
iconAnnotationArr.push(
|
|
135
|
-
<g key={i} className="vertex3-iconAnno" data-click={"icon-annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${x} ${y})`}>
|
|
136
|
-
<Icon
|
|
137
|
-
{...anno}
|
|
138
|
-
shape={anno.shape ?? "square"}
|
|
139
|
-
imageChar={anno.imageChar}
|
|
140
|
-
imageFontFamily={anno.imageFontFamily}
|
|
141
|
-
cornerRadius={cornerRadius}
|
|
142
|
-
stroke={anno.stroke}
|
|
143
|
-
strokeWidth={anno.strokeWidth}
|
|
144
|
-
/>
|
|
145
|
-
</g>
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const textElement = <g data-click={"text"} transform={`translate(${textOffsetX} ${annoOffsetY})`}>
|
|
150
|
-
{!showLabel || text === "" ? <circle r={noLabelRadius} stroke={textboxStroke} fill={textFill} /> : <TextBox
|
|
151
|
-
text={text}
|
|
152
|
-
height={textHeight}
|
|
153
|
-
padding={textPadding}
|
|
154
|
-
strokeWidth={textboxStrokeWidth}
|
|
155
|
-
stroke={textboxStroke}
|
|
156
|
-
fill={textboxFill}
|
|
157
|
-
textFill={textFill}
|
|
158
|
-
fontFamily={textFontFamily}
|
|
159
|
-
cornerRadius={cornerRadius}
|
|
160
|
-
/>}
|
|
161
|
-
</g>;
|
|
162
|
-
|
|
163
|
-
const subTextOffsetX = 0;
|
|
164
|
-
const subTextOffsetY = textShapeHeight + (annotationGutter * 2);
|
|
165
|
-
|
|
166
|
-
const subtextElement = subText.text === "" ? null : <g data-click={"subtext"}
|
|
167
|
-
transform={`translate(${subTextOffsetX} ${subTextOffsetY})`}
|
|
168
|
-
>
|
|
169
|
-
<TextBox
|
|
170
|
-
fill={subText.fill || "#FFFFFF"}
|
|
171
|
-
textFill={subText.textFill || textFill}
|
|
172
|
-
{...subText}
|
|
173
|
-
height={textHeight}
|
|
174
|
-
padding={textPadding}
|
|
175
|
-
strokeWidth={0}
|
|
176
|
-
stroke={textboxStroke}
|
|
177
|
-
fontFamily={textFontFamily}
|
|
178
|
-
cornerRadius={cornerRadius}
|
|
179
|
-
/>
|
|
180
|
-
</g>;
|
|
181
|
-
return <g>
|
|
182
|
-
<g data-click={"icon"}
|
|
183
|
-
transform={`translate(${shapeOffsetX} ${shapeOffsetY})`}
|
|
184
|
-
>
|
|
185
|
-
<Icon
|
|
186
|
-
{...icon}
|
|
187
|
-
strokeWidth={iconBorderWidth}
|
|
188
|
-
shape="circle"
|
|
189
|
-
height={iconFontSize}
|
|
190
|
-
fill={iconBackgroundColor}
|
|
191
|
-
stroke={iconBorderColor}
|
|
192
|
-
imageFontFamily={iconFontFamily}
|
|
193
|
-
imageChar={iconText}
|
|
194
|
-
imageCharFill={iconFontColor}
|
|
195
|
-
padding={iconPadding}
|
|
196
|
-
xOffset={iconOffsetX}
|
|
197
|
-
yOffset={iconOffsetY}
|
|
198
|
-
cornerRadius={cornerRadius}
|
|
199
|
-
shapeRendering={shapeRendering}
|
|
200
|
-
/>
|
|
201
|
-
{iconAnnotationArr}
|
|
202
|
-
</g>
|
|
203
|
-
<g
|
|
204
|
-
transform={`translate(${-fullAnnotationWidth / 2} ${annoOffsetY})`}
|
|
205
|
-
>
|
|
206
|
-
{textElement}
|
|
207
|
-
{annotationArr}
|
|
208
|
-
</g>
|
|
209
|
-
{subtextElement}
|
|
210
|
-
</g>
|
|
211
|
-
;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const CentroidVertex4: PReact.FunctionComponent<IVertex4> = function ({
|
|
215
|
-
id,
|
|
216
|
-
categoryID = "",
|
|
217
|
-
text = "",
|
|
218
|
-
textHeight = 12,
|
|
219
|
-
textPadding = 10,
|
|
220
|
-
textFill = "#287EC4",
|
|
221
|
-
textboxFill = "white",
|
|
222
|
-
textboxStroke = "#CCCCCC",
|
|
223
|
-
textboxStrokeWidth = 1,
|
|
224
|
-
textFontFamily = "Verdana",
|
|
225
|
-
annotationGutter = 2,
|
|
226
|
-
annotations = [],
|
|
227
|
-
iconAnnotations = [],
|
|
228
|
-
cornerRadius,
|
|
229
|
-
icon = {},
|
|
230
|
-
subText = {},
|
|
231
|
-
showLabel = true,
|
|
232
|
-
noLabelRadius = 5,
|
|
233
|
-
|
|
234
|
-
iconBorderWidth = 1,
|
|
235
|
-
iconBorderColor = "#333",
|
|
236
|
-
|
|
237
|
-
iconBackgroundColor = "#fff",
|
|
238
|
-
|
|
239
|
-
iconFontColor = "#000",
|
|
240
|
-
iconFontSize = 20,
|
|
241
|
-
iconFontFamily = "FontAwesome",
|
|
242
|
-
|
|
243
|
-
shapeOffsetX = 0,
|
|
244
|
-
shapeOffsetY = 0,
|
|
245
|
-
iconOffsetX = 0,
|
|
246
|
-
iconOffsetY = 0,
|
|
247
|
-
|
|
248
|
-
iconPadding = 4,
|
|
249
|
-
iconText = "?",
|
|
250
|
-
shapeRendering = "auto"
|
|
251
|
-
}) {
|
|
252
|
-
icon = {
|
|
253
|
-
height: 91,
|
|
254
|
-
padding: 40,
|
|
255
|
-
imageCharFill: "#555555",
|
|
256
|
-
imageFontFamily: "FontAwesome",
|
|
257
|
-
fill: "#FFCC33",
|
|
258
|
-
stroke: "#DFDFDF",
|
|
259
|
-
imageChar: "?",
|
|
260
|
-
strokeWidth: 4,
|
|
261
|
-
yOffset: -15,
|
|
262
|
-
...icon
|
|
263
|
-
};
|
|
264
|
-
subText = {
|
|
265
|
-
text: "",
|
|
266
|
-
fill: "transparent",
|
|
267
|
-
textFill: "#555555",
|
|
268
|
-
...subText
|
|
269
|
-
};
|
|
270
|
-
const props = {
|
|
271
|
-
id,
|
|
272
|
-
categoryID,
|
|
273
|
-
text,
|
|
274
|
-
textHeight,
|
|
275
|
-
textPadding,
|
|
276
|
-
textFill,
|
|
277
|
-
textboxFill,
|
|
278
|
-
textboxStroke,
|
|
279
|
-
textboxStrokeWidth,
|
|
280
|
-
textFontFamily,
|
|
281
|
-
annotationGutter,
|
|
282
|
-
annotations,
|
|
283
|
-
iconAnnotations,
|
|
284
|
-
cornerRadius,
|
|
285
|
-
icon,
|
|
286
|
-
subText,
|
|
287
|
-
showLabel,
|
|
288
|
-
noLabelRadius,
|
|
289
|
-
iconBorderWidth,
|
|
290
|
-
iconBorderColor,
|
|
291
|
-
iconBackgroundColor,
|
|
292
|
-
iconFontColor,
|
|
293
|
-
iconFontSize,
|
|
294
|
-
iconFontFamily,
|
|
295
|
-
shapeOffsetX,
|
|
296
|
-
shapeOffsetY,
|
|
297
|
-
iconOffsetX,
|
|
298
|
-
iconOffsetY,
|
|
299
|
-
iconPadding,
|
|
300
|
-
iconText,
|
|
301
|
-
shapeRendering
|
|
302
|
-
};
|
|
303
|
-
return <Vertex4
|
|
304
|
-
{...props}
|
|
305
|
-
icon={icon}
|
|
306
|
-
subText={subText}
|
|
307
|
-
/>;
|
|
308
|
-
};
|
|
1
|
+
import * as PReact from "./preact-shim.ts";
|
|
2
|
+
import { Utility } from "@hpcc-js/common";
|
|
3
|
+
import { Icon, IconProps } from "./icon.tsx";
|
|
4
|
+
import { TextBox, TextBoxProps } from "./text.tsx";
|
|
5
|
+
import { VertexProps } from "./vertex.tsx";
|
|
6
|
+
|
|
7
|
+
export interface IVertex4Annotation extends IconProps {
|
|
8
|
+
shapeOffsetX?: number;
|
|
9
|
+
shapeOffsetY?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IVertex4 extends VertexProps {
|
|
13
|
+
textboxStrokeWidth?: number;
|
|
14
|
+
annotations?: IVertex4Annotation[];
|
|
15
|
+
iconAnnotations?: IVertex4Annotation[];
|
|
16
|
+
annotationGutter?: number;
|
|
17
|
+
cornerRadius?: number;
|
|
18
|
+
subText?: any;
|
|
19
|
+
noLabelRadius?: number;
|
|
20
|
+
iconBorderWidth?: number;
|
|
21
|
+
iconBorderColor?: string;
|
|
22
|
+
iconBackgroundColor?: string;
|
|
23
|
+
shapeOffsetX?: number;
|
|
24
|
+
shapeOffsetY?: number;
|
|
25
|
+
iconOffsetX?: number;
|
|
26
|
+
iconOffsetY?: number;
|
|
27
|
+
iconPadding?: number;
|
|
28
|
+
iconFontSize?: number;
|
|
29
|
+
iconFontColor?: string;
|
|
30
|
+
iconFontFamily?: string;
|
|
31
|
+
iconText?: string;
|
|
32
|
+
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Vertex4: PReact.FunctionComponent<IVertex4> = ({
|
|
36
|
+
categoryID = "",
|
|
37
|
+
text = "",
|
|
38
|
+
textHeight = 10,
|
|
39
|
+
textPadding = 4,
|
|
40
|
+
textFill = "#287EC4",
|
|
41
|
+
textboxFill = "white",
|
|
42
|
+
textboxStroke = "#CCCCCC",
|
|
43
|
+
textboxStrokeWidth = 1,
|
|
44
|
+
textFontFamily = "Verdana",
|
|
45
|
+
annotationGutter = 2,
|
|
46
|
+
annotations = [],
|
|
47
|
+
iconAnnotations = [],
|
|
48
|
+
cornerRadius = 3,
|
|
49
|
+
icon = {} as IconProps,
|
|
50
|
+
subText = {} as TextBoxProps,
|
|
51
|
+
showLabel = true,
|
|
52
|
+
noLabelRadius = 5,
|
|
53
|
+
|
|
54
|
+
iconBorderWidth = 1,
|
|
55
|
+
iconBorderColor = "#333",
|
|
56
|
+
|
|
57
|
+
iconBackgroundColor = "#fff",
|
|
58
|
+
|
|
59
|
+
iconFontColor = "#000",
|
|
60
|
+
iconFontSize = 20,
|
|
61
|
+
iconFontFamily = "FontAwesome",
|
|
62
|
+
|
|
63
|
+
shapeOffsetX = 0,
|
|
64
|
+
shapeOffsetY = 0,
|
|
65
|
+
iconOffsetX = 0,
|
|
66
|
+
iconOffsetY = 0,
|
|
67
|
+
|
|
68
|
+
iconPadding = 4,
|
|
69
|
+
iconText = "?",
|
|
70
|
+
shapeRendering = "auto"
|
|
71
|
+
}) => {
|
|
72
|
+
icon = {
|
|
73
|
+
height: 50,
|
|
74
|
+
imageChar: "?",
|
|
75
|
+
imageFontFamily: "FontAwesome",
|
|
76
|
+
imageCharFill: "#555555",
|
|
77
|
+
fill: "transparent",
|
|
78
|
+
strokeWidth: 0,
|
|
79
|
+
...icon
|
|
80
|
+
};
|
|
81
|
+
subText = {
|
|
82
|
+
text: "",
|
|
83
|
+
fill: "white",
|
|
84
|
+
textFill: "#555555",
|
|
85
|
+
...subText
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const annoOffsetY = 0;
|
|
89
|
+
const labelWidth = PReact.useMemo(() => {
|
|
90
|
+
return Utility.textSize(text, textFontFamily, textHeight, false).width;
|
|
91
|
+
}, [text, textFontFamily, textHeight]);
|
|
92
|
+
|
|
93
|
+
let labelShapeWidth = 0;
|
|
94
|
+
if (text !== "") {
|
|
95
|
+
labelShapeWidth = labelWidth + (textPadding * 2) + (textboxStrokeWidth * 2);
|
|
96
|
+
}
|
|
97
|
+
let fullAnnotationWidth = labelShapeWidth + annotationGutter;
|
|
98
|
+
const textOffsetX = fullAnnotationWidth - (labelShapeWidth / 2);
|
|
99
|
+
|
|
100
|
+
const textShapeHeight = textHeight + (annotationGutter * 2) + (textboxStrokeWidth * 2);
|
|
101
|
+
const annoWidthArr = annotations.map((anno) => {
|
|
102
|
+
return Utility.textSize(anno.imageChar, anno.imageFontFamily, anno.height, false).width;
|
|
103
|
+
});
|
|
104
|
+
const annotationArr = [];
|
|
105
|
+
let _labelAnnoOffsetX = fullAnnotationWidth;
|
|
106
|
+
annotations.forEach((anno, i) => {
|
|
107
|
+
const annoText = anno.imageChar;
|
|
108
|
+
const annoTextHeight = anno.height ?? textShapeHeight;
|
|
109
|
+
_labelAnnoOffsetX += annoWidthArr[i] + annotationGutter;
|
|
110
|
+
const annoOffsetX = _labelAnnoOffsetX - (annoWidthArr[i] / 2);
|
|
111
|
+
annotationArr.push(
|
|
112
|
+
<g key={i} className="vertex3-anno" data-click={"annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${annoOffsetX} ${annoOffsetY})`}>
|
|
113
|
+
<Icon
|
|
114
|
+
{...anno}
|
|
115
|
+
shape="rectangle"
|
|
116
|
+
width={annoWidthArr[i]}
|
|
117
|
+
height={annoTextHeight}
|
|
118
|
+
imageChar={annoText}
|
|
119
|
+
imageFontFamily={anno.imageFontFamily}
|
|
120
|
+
cornerRadius={cornerRadius}
|
|
121
|
+
strokeWidth={0}
|
|
122
|
+
/>
|
|
123
|
+
</g>
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (annotations.length > 0) {
|
|
128
|
+
fullAnnotationWidth += annotationGutter * (annotations.length - 1);
|
|
129
|
+
}
|
|
130
|
+
const iconAnnotationArr = [];
|
|
131
|
+
iconAnnotations.forEach((anno, i) => {
|
|
132
|
+
const x = anno.shapeOffsetX;
|
|
133
|
+
const y = anno.shapeOffsetY;
|
|
134
|
+
iconAnnotationArr.push(
|
|
135
|
+
<g key={i} className="vertex3-iconAnno" data-click={"icon-annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${x} ${y})`}>
|
|
136
|
+
<Icon
|
|
137
|
+
{...anno}
|
|
138
|
+
shape={anno.shape ?? "square"}
|
|
139
|
+
imageChar={anno.imageChar}
|
|
140
|
+
imageFontFamily={anno.imageFontFamily}
|
|
141
|
+
cornerRadius={cornerRadius}
|
|
142
|
+
stroke={anno.stroke}
|
|
143
|
+
strokeWidth={anno.strokeWidth}
|
|
144
|
+
/>
|
|
145
|
+
</g>
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const textElement = <g data-click={"text"} transform={`translate(${textOffsetX} ${annoOffsetY})`}>
|
|
150
|
+
{!showLabel || text === "" ? <circle r={noLabelRadius} stroke={textboxStroke} fill={textFill} /> : <TextBox
|
|
151
|
+
text={text}
|
|
152
|
+
height={textHeight}
|
|
153
|
+
padding={textPadding}
|
|
154
|
+
strokeWidth={textboxStrokeWidth}
|
|
155
|
+
stroke={textboxStroke}
|
|
156
|
+
fill={textboxFill}
|
|
157
|
+
textFill={textFill}
|
|
158
|
+
fontFamily={textFontFamily}
|
|
159
|
+
cornerRadius={cornerRadius}
|
|
160
|
+
/>}
|
|
161
|
+
</g>;
|
|
162
|
+
|
|
163
|
+
const subTextOffsetX = 0;
|
|
164
|
+
const subTextOffsetY = textShapeHeight + (annotationGutter * 2);
|
|
165
|
+
|
|
166
|
+
const subtextElement = subText.text === "" ? null : <g data-click={"subtext"}
|
|
167
|
+
transform={`translate(${subTextOffsetX} ${subTextOffsetY})`}
|
|
168
|
+
>
|
|
169
|
+
<TextBox
|
|
170
|
+
fill={subText.fill || "#FFFFFF"}
|
|
171
|
+
textFill={subText.textFill || textFill}
|
|
172
|
+
{...subText}
|
|
173
|
+
height={textHeight}
|
|
174
|
+
padding={textPadding}
|
|
175
|
+
strokeWidth={0}
|
|
176
|
+
stroke={textboxStroke}
|
|
177
|
+
fontFamily={textFontFamily}
|
|
178
|
+
cornerRadius={cornerRadius}
|
|
179
|
+
/>
|
|
180
|
+
</g>;
|
|
181
|
+
return <g>
|
|
182
|
+
<g data-click={"icon"}
|
|
183
|
+
transform={`translate(${shapeOffsetX} ${shapeOffsetY})`}
|
|
184
|
+
>
|
|
185
|
+
<Icon
|
|
186
|
+
{...icon}
|
|
187
|
+
strokeWidth={iconBorderWidth}
|
|
188
|
+
shape="circle"
|
|
189
|
+
height={iconFontSize}
|
|
190
|
+
fill={iconBackgroundColor}
|
|
191
|
+
stroke={iconBorderColor}
|
|
192
|
+
imageFontFamily={iconFontFamily}
|
|
193
|
+
imageChar={iconText}
|
|
194
|
+
imageCharFill={iconFontColor}
|
|
195
|
+
padding={iconPadding}
|
|
196
|
+
xOffset={iconOffsetX}
|
|
197
|
+
yOffset={iconOffsetY}
|
|
198
|
+
cornerRadius={cornerRadius}
|
|
199
|
+
shapeRendering={shapeRendering}
|
|
200
|
+
/>
|
|
201
|
+
{iconAnnotationArr}
|
|
202
|
+
</g>
|
|
203
|
+
<g
|
|
204
|
+
transform={`translate(${-fullAnnotationWidth / 2} ${annoOffsetY})`}
|
|
205
|
+
>
|
|
206
|
+
{textElement}
|
|
207
|
+
{annotationArr}
|
|
208
|
+
</g>
|
|
209
|
+
{subtextElement}
|
|
210
|
+
</g>
|
|
211
|
+
;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export const CentroidVertex4: PReact.FunctionComponent<IVertex4> = function ({
|
|
215
|
+
id,
|
|
216
|
+
categoryID = "",
|
|
217
|
+
text = "",
|
|
218
|
+
textHeight = 12,
|
|
219
|
+
textPadding = 10,
|
|
220
|
+
textFill = "#287EC4",
|
|
221
|
+
textboxFill = "white",
|
|
222
|
+
textboxStroke = "#CCCCCC",
|
|
223
|
+
textboxStrokeWidth = 1,
|
|
224
|
+
textFontFamily = "Verdana",
|
|
225
|
+
annotationGutter = 2,
|
|
226
|
+
annotations = [],
|
|
227
|
+
iconAnnotations = [],
|
|
228
|
+
cornerRadius,
|
|
229
|
+
icon = {},
|
|
230
|
+
subText = {},
|
|
231
|
+
showLabel = true,
|
|
232
|
+
noLabelRadius = 5,
|
|
233
|
+
|
|
234
|
+
iconBorderWidth = 1,
|
|
235
|
+
iconBorderColor = "#333",
|
|
236
|
+
|
|
237
|
+
iconBackgroundColor = "#fff",
|
|
238
|
+
|
|
239
|
+
iconFontColor = "#000",
|
|
240
|
+
iconFontSize = 20,
|
|
241
|
+
iconFontFamily = "FontAwesome",
|
|
242
|
+
|
|
243
|
+
shapeOffsetX = 0,
|
|
244
|
+
shapeOffsetY = 0,
|
|
245
|
+
iconOffsetX = 0,
|
|
246
|
+
iconOffsetY = 0,
|
|
247
|
+
|
|
248
|
+
iconPadding = 4,
|
|
249
|
+
iconText = "?",
|
|
250
|
+
shapeRendering = "auto"
|
|
251
|
+
}) {
|
|
252
|
+
icon = {
|
|
253
|
+
height: 91,
|
|
254
|
+
padding: 40,
|
|
255
|
+
imageCharFill: "#555555",
|
|
256
|
+
imageFontFamily: "FontAwesome",
|
|
257
|
+
fill: "#FFCC33",
|
|
258
|
+
stroke: "#DFDFDF",
|
|
259
|
+
imageChar: "?",
|
|
260
|
+
strokeWidth: 4,
|
|
261
|
+
yOffset: -15,
|
|
262
|
+
...icon
|
|
263
|
+
};
|
|
264
|
+
subText = {
|
|
265
|
+
text: "",
|
|
266
|
+
fill: "transparent",
|
|
267
|
+
textFill: "#555555",
|
|
268
|
+
...subText
|
|
269
|
+
};
|
|
270
|
+
const props = {
|
|
271
|
+
id,
|
|
272
|
+
categoryID,
|
|
273
|
+
text,
|
|
274
|
+
textHeight,
|
|
275
|
+
textPadding,
|
|
276
|
+
textFill,
|
|
277
|
+
textboxFill,
|
|
278
|
+
textboxStroke,
|
|
279
|
+
textboxStrokeWidth,
|
|
280
|
+
textFontFamily,
|
|
281
|
+
annotationGutter,
|
|
282
|
+
annotations,
|
|
283
|
+
iconAnnotations,
|
|
284
|
+
cornerRadius,
|
|
285
|
+
icon,
|
|
286
|
+
subText,
|
|
287
|
+
showLabel,
|
|
288
|
+
noLabelRadius,
|
|
289
|
+
iconBorderWidth,
|
|
290
|
+
iconBorderColor,
|
|
291
|
+
iconBackgroundColor,
|
|
292
|
+
iconFontColor,
|
|
293
|
+
iconFontSize,
|
|
294
|
+
iconFontFamily,
|
|
295
|
+
shapeOffsetX,
|
|
296
|
+
shapeOffsetY,
|
|
297
|
+
iconOffsetX,
|
|
298
|
+
iconOffsetY,
|
|
299
|
+
iconPadding,
|
|
300
|
+
iconText,
|
|
301
|
+
shapeRendering
|
|
302
|
+
};
|
|
303
|
+
return <Vertex4
|
|
304
|
+
{...props}
|
|
305
|
+
icon={icon}
|
|
306
|
+
subText={subText}
|
|
307
|
+
/>;
|
|
308
|
+
};
|