|
@@ -1,5 +1,11 @@
|
|
|
import { Path } from "konva/lib/shapes/Path";
|
|
|
-import { injectPoiType, pathsToActShape } from "../../board";
|
|
|
+import {
|
|
|
+ getRealAbsoluteSize,
|
|
|
+ injectPoiType,
|
|
|
+ pathsToActShape,
|
|
|
+} from "../../board";
|
|
|
+import { Label, Tag } from "konva/lib/shapes/Label";
|
|
|
+import { Text } from "konva/lib/shapes/Text";
|
|
|
|
|
|
const svgs = {
|
|
|
wljg: [
|
|
@@ -24,7 +30,7 @@ const svgs = {
|
|
|
};
|
|
|
|
|
|
for (const key in svgs) {
|
|
|
- injectPoiType(key, () => {
|
|
|
+ injectPoiType(key, (attrib, tree) => {
|
|
|
const svgAct = pathsToActShape({
|
|
|
paths: svgs[key],
|
|
|
size: [1000, 800],
|
|
@@ -36,8 +42,45 @@ for (const key in svgs) {
|
|
|
});
|
|
|
|
|
|
const paths = svgAct.shape.find<Path>(".path");
|
|
|
+
|
|
|
+ const label = new Label({ opacity: 0.75, name: "label" });
|
|
|
+ label.add(
|
|
|
+ new Tag({
|
|
|
+ name: "tag",
|
|
|
+ fill: "rgba(0, 0, 0, 0.8)",
|
|
|
+ pointerDirection: "down",
|
|
|
+ pointerWidth: 5,
|
|
|
+ pointerHeight: 5,
|
|
|
+ lineJoin: "round",
|
|
|
+ shadowColor: "black",
|
|
|
+ shadowBlur: 10,
|
|
|
+ shadowOffsetX: 10,
|
|
|
+ shadowOffsetY: 10,
|
|
|
+ shadowOpacity: 0.5,
|
|
|
+ }),
|
|
|
+ new Text({
|
|
|
+ name: "text",
|
|
|
+ text: `${attrib.id}`,
|
|
|
+ fontFamily: "Calibri",
|
|
|
+ fontSize: 10,
|
|
|
+ padding: 3,
|
|
|
+ fill: "white",
|
|
|
+ })
|
|
|
+ );
|
|
|
+ svgAct.shape.add(label);
|
|
|
+
|
|
|
return {
|
|
|
...svgAct,
|
|
|
+ setData(data) {
|
|
|
+ const scale = getRealAbsoluteSize(svgAct.shape, [1, 1]);
|
|
|
+ label.scale({ x: scale[0], y: scale[1] });
|
|
|
+ svgAct.setData(data);
|
|
|
+ if (tree.showLabel) {
|
|
|
+ label.show();
|
|
|
+ } else {
|
|
|
+ label.hide();
|
|
|
+ }
|
|
|
+ },
|
|
|
draging() {
|
|
|
paths.forEach((path) => {
|
|
|
path.fill("#e0403c");
|