@visactor/vgrammar-core 0.14.15 → 0.14.17
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/cjs/graph/attributes/transform.js +7 -3
- package/cjs/graph/attributes/transform.js.map +1 -1
- package/cjs/graph/canvas-renderer.js +2 -1
- package/cjs/graph/canvas-renderer.js.map +1 -1
- package/cjs/graph/glyph-element.js +2 -1
- package/cjs/graph/glyph-element.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interactions/base.js.map +1 -1
- package/cjs/interactions/element-active-by-legend.d.ts +2 -1
- package/cjs/interactions/element-active-by-legend.js +5 -2
- package/cjs/interactions/element-active-by-legend.js.map +1 -1
- package/cjs/interactions/element-active.d.ts +3 -2
- package/cjs/interactions/element-active.js +4 -2
- package/cjs/interactions/element-active.js.map +1 -1
- package/cjs/interactions/element-highlight-by-group.d.ts +2 -2
- package/cjs/interactions/element-highlight-by-group.js +4 -3
- package/cjs/interactions/element-highlight-by-group.js.map +1 -1
- package/cjs/interactions/element-highlight-by-key.d.ts +2 -2
- package/cjs/interactions/element-highlight-by-key.js +3 -17
- package/cjs/interactions/element-highlight-by-key.js.map +1 -1
- package/cjs/interactions/element-highlight-by-legend.d.ts +2 -1
- package/cjs/interactions/element-highlight-by-legend.js +6 -3
- package/cjs/interactions/element-highlight-by-legend.js.map +1 -1
- package/cjs/interactions/element-highlight-by-name.d.ts +2 -1
- package/cjs/interactions/element-highlight-by-name.js +5 -2
- package/cjs/interactions/element-highlight-by-name.js.map +1 -1
- package/cjs/interactions/element-highlight.d.ts +1 -1
- package/cjs/interactions/element-highlight.js +9 -6
- package/cjs/interactions/element-highlight.js.map +1 -1
- package/cjs/interactions/element-select.d.ts +1 -1
- package/cjs/interactions/element-select.js +8 -8
- package/cjs/interactions/element-select.js.map +1 -1
- package/cjs/semantic-marks/text.js.map +1 -1
- package/cjs/view/mark-animate-mixin.js +1 -1
- package/cjs/view/mark-animate-mixin.js.map +1 -1
- package/es/graph/attributes/transform.js +7 -3
- package/es/graph/attributes/transform.js.map +1 -1
- package/es/graph/canvas-renderer.js +2 -1
- package/es/graph/canvas-renderer.js.map +1 -1
- package/es/graph/glyph-element.js +2 -1
- package/es/graph/glyph-element.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interactions/base.js.map +1 -1
- package/es/interactions/brush-base.js +2 -1
- package/es/interactions/element-active-by-legend.d.ts +2 -1
- package/es/interactions/element-active-by-legend.js +5 -2
- package/es/interactions/element-active-by-legend.js.map +1 -1
- package/es/interactions/element-active.d.ts +3 -2
- package/es/interactions/element-active.js +5 -4
- package/es/interactions/element-active.js.map +1 -1
- package/es/interactions/element-highlight-by-group.d.ts +2 -2
- package/es/interactions/element-highlight-by-group.js +4 -3
- package/es/interactions/element-highlight-by-group.js.map +1 -1
- package/es/interactions/element-highlight-by-key.d.ts +2 -2
- package/es/interactions/element-highlight-by-key.js +3 -17
- package/es/interactions/element-highlight-by-key.js.map +1 -1
- package/es/interactions/element-highlight-by-legend.d.ts +2 -1
- package/es/interactions/element-highlight-by-legend.js +6 -3
- package/es/interactions/element-highlight-by-legend.js.map +1 -1
- package/es/interactions/element-highlight-by-name.d.ts +2 -1
- package/es/interactions/element-highlight-by-name.js +5 -2
- package/es/interactions/element-highlight-by-name.js.map +1 -1
- package/es/interactions/element-highlight.d.ts +1 -1
- package/es/interactions/element-highlight.js +9 -6
- package/es/interactions/element-highlight.js.map +1 -1
- package/es/interactions/element-select.d.ts +1 -1
- package/es/interactions/element-select.js +8 -8
- package/es/interactions/element-select.js.map +1 -1
- package/es/interactions/fish-eye.js +2 -1
- package/es/interactions/index.js +1 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/toggle-state-mixin.js +1 -1
- package/es/parse/coordinate.js +1 -1
- package/es/parse/event.js +1 -1
- package/es/parse/mark.js +1 -1
- package/es/parse/option.js +1 -2
- package/es/parse/scale.js +1 -1
- package/es/parse/transform.js +1 -1
- package/es/parse/util.js +1 -1
- package/es/parse/view.js +1 -1
- package/es/semantic-marks/text.js.map +1 -1
- package/es/view/mark-animate-mixin.js +1 -1
- package/es/view/mark-animate-mixin.js.map +1 -1
- package/package.json +12 -12
|
@@ -49,13 +49,17 @@ exports.transformsByType = {
|
|
|
49
49
|
storedAttrs: "sizeAttrs"
|
|
50
50
|
} ],
|
|
51
51
|
[enums_1.GrammarMarkType.text]: [ {
|
|
52
|
-
channels: [ "text", "limit", "autoLimit", "maxLineWidth", "textType" ],
|
|
52
|
+
channels: [ "text", "limit", "autoLimit", "maxLineWidth", "textType", "_originText" ],
|
|
53
53
|
transform: (graphicAttributes, nextAttrs, storedAttrs) => {
|
|
54
|
-
var _a, _b;
|
|
54
|
+
var _a, _b, _c, _d;
|
|
55
55
|
const limit = null !== (_a = storedAttrs.limit) && void 0 !== _a ? _a : 1 / 0, autoLimit = null !== (_b = storedAttrs.autoLimit) && void 0 !== _b ? _b : 1 / 0, maxWidth = Math.min(limit, autoLimit), isTextConfig = (0,
|
|
56
56
|
vutils_1.isPlainObject)(storedAttrs.text) && !(0, vutils_1.isNil)(storedAttrs.text.text), text = isTextConfig ? storedAttrs.text.text : storedAttrs.text;
|
|
57
57
|
Array.isArray(text), graphicAttributes.maxLineWidth = maxWidth === 1 / 0 ? storedAttrs.maxLineWidth : maxWidth,
|
|
58
|
-
|
|
58
|
+
isTextConfig || storedAttrs.textType ? "rich" === storedAttrs.text.type || "rich" === storedAttrs.textType ? graphicAttributes.textConfig = text : "html" === storedAttrs.text.type ? (graphicAttributes.html = text,
|
|
59
|
+
graphicAttributes.text = null !== (_c = storedAttrs._originText) && void 0 !== _c ? _c : "",
|
|
60
|
+
graphicAttributes.renderable = !1) : "react" === storedAttrs.text.type ? (graphicAttributes.react = text,
|
|
61
|
+
graphicAttributes.text = null !== (_d = storedAttrs._originText) && void 0 !== _d ? _d : "",
|
|
62
|
+
graphicAttributes.renderable = !1) : graphicAttributes.text = text : graphicAttributes.text = text;
|
|
59
63
|
},
|
|
60
64
|
storedAttrs: "limitAttrs"
|
|
61
65
|
} ],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/attributes/transform.ts"],"names":[],"mappings":";;;AAAA,6CAAsF;AAGtF,oCAA2C;AAC3C,uCAA0C;AAC1C,qCAAsE;AAEtE,SAAS,qBAAqB,CAC5B,IAAY,EACZ,QAAkB,EAClB,iBAAsB,EACtB,SAAc,EACd,OAAiB,EACjB,QAAgB;IAEhB,MAAM,eAAe,GAAI,OAAyB,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE9F,IAAI,eAAe,EAAE;QACnB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACzB,IAAI,OAAO,IAAI,SAAS,EAAE;gBACxB,eAAe,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;aAC/C;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;KACxB;IACD,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACH,iBAAiB,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACtC,OAAO,WAAW,CAAC;AACrB,CAAC;AAEY,QAAA,gBAAgB,GAAyC;IACpE,MAAM,EAAE;QACN;YACE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,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S,CAAC,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;yBAChE;6BAAM;4BACL,SAAS,CAAC,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;yBACzD;qBACF;oBAED,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;oBACnB,aAAa,GAAG,IAAI,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,aAAa,EAAE;gBAClB,IAAI,yBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBAClC,IAAA,iCAAwB,EAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;iBAC7D;qBAAM;oBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;iBACzC;aACF;QACH,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACxB,IAAI,yBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAClC,IAAA,iCAAwB,EAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;aAC7D;iBAAM;gBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA5DW,QAAA,mBAAmB,uBA4D9B","file":"transform.js","sourcesContent":["import { has, isNil, isPlainObject, isString, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IGlyphElement } from '../../types/element';\nimport type { AttributeTransform, MarkType } from '../../types/mark';\nimport { GrammarMarkType } from '../enums';\nimport { getRulePoints } from './helpers';\nimport { commonAttributes, transformCommonAttribute } from './common';\n\nfunction storeOriginAttributes(\n name: string,\n channels: string[],\n graphicAttributes: any,\n nextAttrs: any,\n element: IElement,\n markName: string\n): Record<string, any> {\n const prevStoredAttrs = (element as IGlyphElement).getGraphicAttribute(name, false, markName);\n\n if (prevStoredAttrs) {\n channels.forEach(channel => {\n if (channel in nextAttrs) {\n prevStoredAttrs[channel] = nextAttrs[channel];\n }\n });\n\n return prevStoredAttrs;\n }\n const storedAttrs = {};\n channels.forEach(channel => {\n storedAttrs[channel] = nextAttrs[channel];\n });\n graphicAttributes[name] = storedAttrs;\n return storedAttrs;\n}\n\nexport const transformsByType: Record<string, AttributeTransform[]> = {\n rect3d: [\n {\n channels: ['x', 'y', 'z', 'x1', 'y1', 'width', 'height', 'length'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n\n // length\n if (isValidNumber(nextAttrs.length) || (!isValidNumber(nextAttrs.z1) && isValidNumber(storedAttrs.length))) {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n } else if (isValidNumber(nextAttrs.z1) || (!isValidNumber(nextAttrs.length) && isValidNumber(storedAttrs.z1))) {\n graphicAttributes.z = Math.min(storedAttrs.z, storedAttrs.z1);\n graphicAttributes.length = Math.abs(storedAttrs.z1 - storedAttrs.z);\n } else {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n [GrammarMarkType.text]: [\n {\n channels: ['text', 'limit', 'autoLimit', 'maxLineWidth', 'textType'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const limit = storedAttrs.limit ?? Infinity;\n const autoLimit = storedAttrs.autoLimit ?? Infinity;\n const maxWidth = Math.min(limit, autoLimit);\n const isTextConfig = isPlainObject(storedAttrs.text) && !isNil(storedAttrs.text.text);\n const text = isTextConfig ? storedAttrs.text.text : storedAttrs.text;\n\n if (Array.isArray(text)) {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n } else {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n }\n\n if (isTextConfig || storedAttrs.textType) {\n if (storedAttrs.text.type === 'rich' || storedAttrs.textType === 'rich') {\n graphicAttributes.textConfig = text;\n } else {\n graphicAttributes.text = text;\n }\n } else {\n graphicAttributes.text = text;\n }\n },\n storedAttrs: 'limitAttrs'\n }\n ],\n [GrammarMarkType.rule]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const points = getRulePoints(storedAttrs);\n graphicAttributes.points = points;\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n },\n storedAttrs: 'pointAttrs'\n }\n ],\n [GrammarMarkType.symbol]: [\n {\n channels: ['shape', 'symbolType'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.symbolType = nextAttrs.shape ?? nextAttrs.symbolType;\n }\n },\n {\n channels: ['image', 'fill', 'background'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n if (nextAttrs.image) {\n graphicAttributes.background = nextAttrs.image;\n graphicAttributes.fill = false;\n } else if (storedAttrs.image) {\n graphicAttributes.background = storedAttrs.image;\n graphicAttributes.fill = false;\n } else {\n graphicAttributes.fill = storedAttrs.fill;\n graphicAttributes.background = storedAttrs.background;\n }\n },\n storedAttrs: 'imageAttrs'\n }\n ]\n};\n\nexport function cloneTransformAttributes(markType: MarkType, attributes: any) {\n const transforms = transformsByType[markType] ?? [];\n return transforms.reduce((clonedAttributes, transform) => {\n transform.channels.forEach(channel => {\n if (has(attributes, channel)) {\n clonedAttributes[channel] = attributes[channel];\n }\n });\n return clonedAttributes;\n }, {} as any);\n}\n\nexport const transformAttributes = (\n markType: MarkType | AttributeTransform[],\n nextAttrs: any,\n element: IElement,\n markName?: string\n) => {\n const graphicAttributes = {};\n const changedKeys = nextAttrs ? Object.keys(nextAttrs) : [];\n const transforms: AttributeTransform[] = isString(markType)\n ? transformsByType[markType]\n : (markType as AttributeTransform[]);\n\n if (transforms && transforms.length) {\n const tags: boolean[] = [];\n\n changedKeys.forEach(key => {\n let isTransformed = false;\n\n transforms.forEach((transform, index) => {\n if (transform.channels.includes(key)) {\n if (!tags[index]) {\n if (transform.storedAttrs) {\n const storedAttrs = storeOriginAttributes(\n transform.storedAttrs,\n transform.channels,\n graphicAttributes,\n nextAttrs,\n element,\n markName\n );\n transform.transform(graphicAttributes, nextAttrs, storedAttrs);\n } else {\n transform.transform(graphicAttributes, nextAttrs, null);\n }\n }\n // 记录一下,不重复处理\n tags[index] = true;\n isTransformed = true;\n }\n });\n\n if (!isTransformed) {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n }\n });\n } else {\n changedKeys.forEach(key => {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n });\n }\n\n return graphicAttributes;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/attributes/transform.ts"],"names":[],"mappings":";;;AAAA,6CAAsF;AAGtF,oCAA2C;AAC3C,uCAA0C;AAC1C,qCAAsE;AAEtE,SAAS,qBAAqB,CAC5B,IAAY,EACZ,QAAkB,EAClB,iBAAsB,EACtB,SAAc,EACd,OAAiB,EACjB,QAAgB;IAEhB,MAAM,eAAe,GAAI,OAAyB,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE9F,IAAI,eAAe,EAAE;QACnB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACzB,IAAI,OAAO,IAAI,SAAS,EAAE;gBACxB,eAAe,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;aAC/C;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;KACxB;IACD,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACH,iBAAiB,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACtC,OAAO,WAAW,CAAC;AACrB,CAAC;AAEY,QAAA,gBAAgB,GAAyC;IACpE,MAAM,EAAE;QACN;YACE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE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BAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;aAC7D;iBAAM;gBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA5DW,QAAA,mBAAmB,uBA4D9B","file":"transform.js","sourcesContent":["import { has, isNil, isPlainObject, isString, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IGlyphElement } from '../../types/element';\nimport type { AttributeTransform, MarkType } from '../../types/mark';\nimport { GrammarMarkType } from '../enums';\nimport { getRulePoints } from './helpers';\nimport { commonAttributes, transformCommonAttribute } from './common';\n\nfunction storeOriginAttributes(\n name: string,\n channels: string[],\n graphicAttributes: any,\n nextAttrs: any,\n element: IElement,\n markName: string\n): Record<string, any> {\n const prevStoredAttrs = (element as IGlyphElement).getGraphicAttribute(name, false, markName);\n\n if (prevStoredAttrs) {\n channels.forEach(channel => {\n if (channel in nextAttrs) {\n prevStoredAttrs[channel] = nextAttrs[channel];\n }\n });\n\n return prevStoredAttrs;\n }\n const storedAttrs = {};\n channels.forEach(channel => {\n storedAttrs[channel] = nextAttrs[channel];\n });\n graphicAttributes[name] = storedAttrs;\n return storedAttrs;\n}\n\nexport const transformsByType: Record<string, AttributeTransform[]> = {\n rect3d: [\n {\n channels: ['x', 'y', 'z', 'x1', 'y1', 'width', 'height', 'length'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n\n // length\n if (isValidNumber(nextAttrs.length) || (!isValidNumber(nextAttrs.z1) && isValidNumber(storedAttrs.length))) {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n } else if (isValidNumber(nextAttrs.z1) || (!isValidNumber(nextAttrs.length) && isValidNumber(storedAttrs.z1))) {\n graphicAttributes.z = Math.min(storedAttrs.z, storedAttrs.z1);\n graphicAttributes.length = Math.abs(storedAttrs.z1 - storedAttrs.z);\n } else {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n [GrammarMarkType.text]: [\n {\n channels: ['text', 'limit', 'autoLimit', 'maxLineWidth', 'textType', '_originText'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const limit = storedAttrs.limit ?? Infinity;\n const autoLimit = storedAttrs.autoLimit ?? Infinity;\n const maxWidth = Math.min(limit, autoLimit);\n const isTextConfig = isPlainObject(storedAttrs.text) && !isNil(storedAttrs.text.text);\n const text = isTextConfig ? storedAttrs.text.text : storedAttrs.text;\n\n if (Array.isArray(text)) {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n } else {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n }\n\n if (isTextConfig || storedAttrs.textType) {\n if (storedAttrs.text.type === 'rich' || storedAttrs.textType === 'rich') {\n graphicAttributes.textConfig = text;\n } else if (storedAttrs.text.type === 'html') {\n graphicAttributes.html = text;\n graphicAttributes.text = storedAttrs._originText ?? '';\n graphicAttributes.renderable = false;\n } else if (storedAttrs.text.type === 'react') {\n graphicAttributes.react = text;\n graphicAttributes.text = storedAttrs._originText ?? '';\n graphicAttributes.renderable = false;\n } else {\n graphicAttributes.text = text;\n }\n } else {\n graphicAttributes.text = text;\n }\n },\n storedAttrs: 'limitAttrs'\n }\n ],\n [GrammarMarkType.rule]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const points = getRulePoints(storedAttrs);\n graphicAttributes.points = points;\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n },\n storedAttrs: 'pointAttrs'\n }\n ],\n [GrammarMarkType.symbol]: [\n {\n channels: ['shape', 'symbolType'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.symbolType = nextAttrs.shape ?? nextAttrs.symbolType;\n }\n },\n {\n channels: ['image', 'fill', 'background'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n if (nextAttrs.image) {\n graphicAttributes.background = nextAttrs.image;\n graphicAttributes.fill = false;\n } else if (storedAttrs.image) {\n graphicAttributes.background = storedAttrs.image;\n graphicAttributes.fill = false;\n } else {\n graphicAttributes.fill = storedAttrs.fill;\n graphicAttributes.background = storedAttrs.background;\n }\n },\n storedAttrs: 'imageAttrs'\n }\n ]\n};\n\nexport function cloneTransformAttributes(markType: MarkType, attributes: any) {\n const transforms = transformsByType[markType] ?? [];\n return transforms.reduce((clonedAttributes, transform) => {\n transform.channels.forEach(channel => {\n if (has(attributes, channel)) {\n clonedAttributes[channel] = attributes[channel];\n }\n });\n return clonedAttributes;\n }, {} as any);\n}\n\nexport const transformAttributes = (\n markType: MarkType | AttributeTransform[],\n nextAttrs: any,\n element: IElement,\n markName?: string\n) => {\n const graphicAttributes = {};\n const changedKeys = nextAttrs ? Object.keys(nextAttrs) : [];\n const transforms: AttributeTransform[] = isString(markType)\n ? transformsByType[markType]\n : (markType as AttributeTransform[]);\n\n if (transforms && transforms.length) {\n const tags: boolean[] = [];\n\n changedKeys.forEach(key => {\n let isTransformed = false;\n\n transforms.forEach((transform, index) => {\n if (transform.channels.includes(key)) {\n if (!tags[index]) {\n if (transform.storedAttrs) {\n const storedAttrs = storeOriginAttributes(\n transform.storedAttrs,\n transform.channels,\n graphicAttributes,\n nextAttrs,\n element,\n markName\n );\n transform.transform(graphicAttributes, nextAttrs, storedAttrs);\n } else {\n transform.transform(graphicAttributes, nextAttrs, null);\n }\n }\n // 记录一下,不重复处理\n tags[index] = true;\n isTransformed = true;\n }\n });\n\n if (!isTransformed) {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n }\n });\n } else {\n changedKeys.forEach(key => {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n });\n }\n\n return graphicAttributes;\n};\n"]}
|
|
@@ -104,7 +104,8 @@ class CanvasRenderer {
|
|
|
104
104
|
ticker: viewOptions.ticker,
|
|
105
105
|
supportsTouchEvents: viewOptions.supportsTouchEvents,
|
|
106
106
|
supportsPointerEvents: viewOptions.supportsPointerEvents,
|
|
107
|
-
ReactDOM: viewOptions.ReactDOM
|
|
107
|
+
ReactDOM: viewOptions.ReactDOM,
|
|
108
|
+
autoRefresh: viewOptions.autoRefresh
|
|
108
109
|
});
|
|
109
110
|
(null === (_b = viewOptions.options3d) || void 0 === _b ? void 0 : _b.enable) && stage.set3dOptions(viewOptions.options3d),
|
|
110
111
|
stage.enableIncrementalAutoRender(), this._viewBox = viewOptions.viewBox, this._view.emit(enums_1.HOOK_EVENT.AFTER_CREATE_VRENDER_STAGE),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/canvas-renderer.ts"],"names":[],"mappings":";;AAEA,6CAA4C;AAG5C,yDAA0E;AAG1E,mCAAqC;AAGrC,6CAA0C;AAE1C,MAAqB,cAAc;IAajC,YAAY,IAAW;QAqPf,0BAAqB,GAAG,GAAG,EAAE;YACnC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE;gBACxD,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;aACjC;YAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAU,CAAC,kBAAkB,CAAC,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAU,CAAC,yBAAyB,CAAC,CAAC;QACxD,CAAC,CAAC;QA3PA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,UAAU,CAAC,KAAa,EAAE,MAAc,EAAE,OAAqB,EAAE,WAA6B;QAC5F,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAEhC,IAAI,CAAC,SAAS,EAAE,CAAC;QAGjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;;QACH,OAAO,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC;IAC7B,CAAC;IAED,iBAA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,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAE5C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YAEpB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YAC3C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;SAC7B;IACH,CAAC;CAUF;AA1QD,iCA0QC","file":"canvas-renderer.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isObject } from '@visactor/vutils';\nimport type { IEventTarget, IColor, ILayer, Stage } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { createStage, waitForAllSubLayers } from '@visactor/vrender-core';\nimport type { IViewOptions, IView, IMark, IViewEventConfig } from '../types';\nimport type { IRenderer } from '../types/renderer';\nimport { HOOK_EVENT } from './enums';\nimport type { DragNDrop } from '@visactor/vrender-kits';\nimport type { Gesture } from '@visactor/vrender-kits';\nimport { Factory } from '../core/factory';\n\nexport default class CanvasRenderer implements IRenderer {\n private _width: number;\n private _height: number;\n\n private _view: IView;\n private _viewOptions: IViewOptions;\n private _eventConfig: IViewEventConfig;\n private _stage: Stage;\n private _layer: ILayer;\n private _dragController: DragNDrop;\n private _gestureController: Gesture;\n private _viewBox: IBoundsLike;\n\n constructor(view: IView) {\n this._view = view;\n }\n\n initialize(width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) {\n this._width = width;\n this._height = height;\n this._viewOptions = options;\n this._eventConfig = eventConfig;\n\n this.initStage();\n\n // this method will invoke resize to size the canvas appropriately\n return this;\n }\n\n stage() {\n return this._stage ?? null;\n }\n\n gestureController() {\n return this._gestureController ?? null;\n }\n\n canvas() {\n if (this._stage) {\n return this._stage.window.getNativeHandler().nativeCanvas;\n }\n return null;\n }\n\n context() {\n if (this._stage) {\n return this._stage.window.getContext().nativeContext;\n }\n return null;\n }\n\n combineIncrementalLayers() {\n if (this._stage) {\n waitForAllSubLayers(this._stage as any).then(() => {\n // stage might be null in current tick\n if (this._stage) {\n this._stage.defaultLayer.combineSubLayer();\n }\n });\n }\n return this;\n }\n\n background(color: IColor) {\n if (this._stage) {\n this._stage.background = color;\n return this;\n }\n }\n\n setDpr(resolution: number, redraw: boolean) {\n this._stage?.setDpr?.(resolution);\n if (redraw) {\n this.renderNextFrame();\n }\n return this;\n }\n\n shouldResize(width: number, height: number) {\n return width !== this._width || height !== this._height;\n }\n\n resize(width: number, height: number) {\n this._view.emit(HOOK_EVENT.BEFORE_STAGE_RESIZE);\n if (this.shouldResize(width, height)) {\n this._width = width;\n this._height = height;\n this._stage && this._stage.resize(width, height);\n }\n\n this._view.emit(HOOK_EVENT.AFTER_STAGE_RESIZE);\n\n return this;\n }\n\n setViewBox(viewBox: IBoundsLike, rerender: boolean = true) {\n if (!this._stage) {\n return this;\n }\n if (\n viewBox &&\n (!this._viewBox ||\n viewBox.x1 !== this._viewBox.x1 ||\n viewBox.x2 !== this._viewBox.x2 ||\n viewBox.y1 !== this._viewBox.y1 ||\n viewBox.y2 !== this._viewBox.y2)\n ) {\n this._viewBox = viewBox;\n\n // FIXME: vRender\n this._stage.setViewBox(viewBox.x1, viewBox.y1, viewBox.x2 - viewBox.x1, viewBox.y2 - viewBox.y1, rerender);\n }\n return this;\n }\n\n render(immediately: boolean = false) {\n this._view.emit(HOOK_EVENT.BEFORE_VRENDER_DRAW);\n\n this.initStage();\n\n // disable dirty bounds when render is called\n this._stage.disableDirtyBounds();\n this._stage.afterNextRender(this.handleAfterNextRender);\n\n // render immediately and skip render in next frame\n if (immediately) {\n this._stage.render();\n\n this._view.emit(HOOK_EVENT.AFTER_VRENDER_DRAW);\n }\n return this;\n }\n\n renderNextFrame() {\n this.initStage();\n\n this._stage.renderNextFrame();\n\n return this;\n }\n\n toCanvas() {\n if (this._stage) {\n return this._stage.toCanvas();\n }\n return null;\n }\n\n preventRender(tag: boolean) {\n if (this._stage) {\n this._stage.preventRender(tag);\n }\n }\n\n // toImageData() {\n // if (this._stage) {\n // return this._stage.toImageData();\n // }\n // return null;\n // }\n\n release() {\n this._view.traverseMarkTree((mark: IMark) => {\n mark.release();\n });\n\n if (this._dragController) {\n this._dragController.release();\n }\n if (this._gestureController) {\n this._gestureController.release();\n }\n\n if (this._stage !== (this._viewOptions?.stage as unknown as Stage)) {\n // don't release the stage created by outside\n this._stage.release();\n }\n\n this._stage = null;\n this._layer = null;\n this._dragController = null;\n this._gestureController = null;\n }\n\n private createStage() {\n this._view.emit(HOOK_EVENT.BEFORE_CREATE_VRENDER_STAGE);\n\n const viewOptions = this._viewOptions;\n\n const stage =\n (viewOptions.stage as unknown as Stage) ??\n createStage({\n width: this._width,\n height: this._height,\n renderStyle: viewOptions.renderStyle,\n viewBox: viewOptions.viewBox,\n dpr: viewOptions.dpr,\n canvas: viewOptions.renderCanvas,\n canvasControled: viewOptions.canvasControled,\n container: viewOptions.container,\n title: viewOptions.rendererTitle,\n beforeRender: viewOptions.beforeRender,\n afterRender: viewOptions.afterRender,\n disableDirtyBounds: true,\n autoRender: true,\n pluginList: viewOptions.pluginList,\n enableHtmlAttribute: viewOptions.enableHtmlAttribute,\n optimize: viewOptions.optimize,\n ticker: viewOptions.ticker,\n supportsTouchEvents: viewOptions.supportsTouchEvents,\n supportsPointerEvents: viewOptions.supportsPointerEvents,\n ReactDOM: viewOptions.ReactDOM\n });\n\n if (viewOptions.options3d?.enable) {\n stage.set3dOptions(viewOptions.options3d);\n }\n\n stage.enableIncrementalAutoRender();\n\n this._viewBox = viewOptions.viewBox;\n this._view.emit(HOOK_EVENT.AFTER_CREATE_VRENDER_STAGE);\n\n this._view.emit(HOOK_EVENT.BEFORE_CREATE_VRENDER_LAYER);\n const layer = viewOptions.layer ?? (stage.defaultLayer as ILayer);\n this._view.emit(HOOK_EVENT.AFTER_CREATE_VRENDER_LAYER);\n\n if (this._eventConfig?.drag && Factory.getStageEventPlugin('drag')) {\n // 允许 drag 事件\n this._dragController = new (Factory.getStageEventPlugin('drag'))(stage as unknown as IEventTarget) as DragNDrop;\n }\n if (this._eventConfig?.gesture && Factory.getStageEventPlugin('gesture')) {\n const gestureConfig = isObject(this._eventConfig.gesture) ? this._eventConfig.gesture : {};\n // 允许手势\n this._gestureController = new (Factory.getStageEventPlugin('gesture'))(\n stage as unknown as IEventTarget,\n gestureConfig\n ) as Gesture;\n }\n\n return {\n stage,\n layer\n };\n }\n\n private initStage() {\n if (!this._stage) {\n const { stage, layer } = this.createStage();\n\n this._stage = stage;\n this._layer = layer;\n\n const background = this._view.background();\n this.background(background);\n }\n }\n\n private handleAfterNextRender = () => {\n if (this._stage && !this._viewOptions.disableDirtyBounds) {\n this._stage.enableDirtyBounds();\n }\n\n this._view.emit(HOOK_EVENT.AFTER_VRENDER_DRAW);\n this._view.emit(HOOK_EVENT.AFTER_VRENDER_NEXT_RENDER);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/canvas-renderer.ts"],"names":[],"mappings":";;AAEA,6CAA4C;AAG5C,yDAA0E;AAG1E,mCAAqC;AAGrC,6CAA0C;AAE1C,MAAqB,cAAc;IAajC,YAAY,IAAW;QAsPf,0BAAqB,GAAG,GAAG,EAAE;YACnC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE;gBACxD,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;aACjC;YAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAU,CAAC,kBAAkB,CAAC,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAU,CAAC,yBAAyB,CAAC,CAAC;QACxD,CAAC,CAAC;QA5PA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,UAAU,CAAC,KAAa,EAAE,MAAc,EAAE,OAAqB,EAAE,WAA6B;QAC5F,IAAI,CAAC,MAAM,GAAG,KAAK,C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,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAE3F,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,iBAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CACpE,KAAgC,EAChC,aAAa,CACH,CAAC;SACd;QAED,OAAO;YACL,KAAK;YACL,KAAK;SACN,CAAC;IACJ,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAE5C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YAEpB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YAC3C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;SAC7B;IACH,CAAC;CAUF;AA3QD,iCA2QC","file":"canvas-renderer.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isObject } from '@visactor/vutils';\nimport type { IEventTarget, IColor, ILayer, Stage } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { createStage, waitForAllSubLayers } from '@visactor/vrender-core';\nimport type { IViewOptions, IView, IMark, IViewEventConfig } from '../types';\nimport type { IRenderer } from '../types/renderer';\nimport { HOOK_EVENT } from './enums';\nimport type { DragNDrop } from '@visactor/vrender-kits';\nimport type { Gesture } from '@visactor/vrender-kits';\nimport { Factory } from '../core/factory';\n\nexport default class CanvasRenderer implements IRenderer {\n private _width: number;\n private _height: number;\n\n private _view: IView;\n private _viewOptions: IViewOptions;\n private _eventConfig: IViewEventConfig;\n private _stage: Stage;\n private _layer: ILayer;\n private _dragController: DragNDrop;\n private _gestureController: Gesture;\n private _viewBox: IBoundsLike;\n\n constructor(view: IView) {\n this._view = view;\n }\n\n initialize(width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) {\n this._width = width;\n this._height = height;\n this._viewOptions = options;\n this._eventConfig = eventConfig;\n\n this.initStage();\n\n // this method will invoke resize to size the canvas appropriately\n return this;\n }\n\n stage() {\n return this._stage ?? null;\n }\n\n gestureController() {\n return this._gestureController ?? null;\n }\n\n canvas() {\n if (this._stage) {\n return this._stage.window.getNativeHandler().nativeCanvas;\n }\n return null;\n }\n\n context() {\n if (this._stage) {\n return this._stage.window.getContext().nativeContext;\n }\n return null;\n }\n\n combineIncrementalLayers() {\n if (this._stage) {\n waitForAllSubLayers(this._stage as any).then(() => {\n // stage might be null in current tick\n if (this._stage) {\n this._stage.defaultLayer.combineSubLayer();\n }\n });\n }\n return this;\n }\n\n background(color: IColor) {\n if (this._stage) {\n this._stage.background = color;\n return this;\n }\n }\n\n setDpr(resolution: number, redraw: boolean) {\n this._stage?.setDpr?.(resolution);\n if (redraw) {\n this.renderNextFrame();\n }\n return this;\n }\n\n shouldResize(width: number, height: number) {\n return width !== this._width || height !== this._height;\n }\n\n resize(width: number, height: number) {\n this._view.emit(HOOK_EVENT.BEFORE_STAGE_RESIZE);\n if (this.shouldResize(width, height)) {\n this._width = width;\n this._height = height;\n this._stage && this._stage.resize(width, height);\n }\n\n this._view.emit(HOOK_EVENT.AFTER_STAGE_RESIZE);\n\n return this;\n }\n\n setViewBox(viewBox: IBoundsLike, rerender: boolean = true) {\n if (!this._stage) {\n return this;\n }\n if (\n viewBox &&\n (!this._viewBox ||\n viewBox.x1 !== this._viewBox.x1 ||\n viewBox.x2 !== this._viewBox.x2 ||\n viewBox.y1 !== this._viewBox.y1 ||\n viewBox.y2 !== this._viewBox.y2)\n ) {\n this._viewBox = viewBox;\n\n // FIXME: vRender\n this._stage.setViewBox(viewBox.x1, viewBox.y1, viewBox.x2 - viewBox.x1, viewBox.y2 - viewBox.y1, rerender);\n }\n return this;\n }\n\n render(immediately: boolean = false) {\n this._view.emit(HOOK_EVENT.BEFORE_VRENDER_DRAW);\n\n this.initStage();\n\n // disable dirty bounds when render is called\n this._stage.disableDirtyBounds();\n this._stage.afterNextRender(this.handleAfterNextRender);\n\n // render immediately and skip render in next frame\n if (immediately) {\n this._stage.render();\n\n this._view.emit(HOOK_EVENT.AFTER_VRENDER_DRAW);\n }\n return this;\n }\n\n renderNextFrame() {\n this.initStage();\n\n this._stage.renderNextFrame();\n\n return this;\n }\n\n toCanvas() {\n if (this._stage) {\n return this._stage.toCanvas();\n }\n return null;\n }\n\n preventRender(tag: boolean) {\n if (this._stage) {\n this._stage.preventRender(tag);\n }\n }\n\n // toImageData() {\n // if (this._stage) {\n // return this._stage.toImageData();\n // }\n // return null;\n // }\n\n release() {\n this._view.traverseMarkTree((mark: IMark) => {\n mark.release();\n });\n\n if (this._dragController) {\n this._dragController.release();\n }\n if (this._gestureController) {\n this._gestureController.release();\n }\n\n if (this._stage !== (this._viewOptions?.stage as unknown as Stage)) {\n // don't release the stage created by outside\n this._stage.release();\n }\n\n this._stage = null;\n this._layer = null;\n this._dragController = null;\n this._gestureController = null;\n }\n\n private createStage() {\n this._view.emit(HOOK_EVENT.BEFORE_CREATE_VRENDER_STAGE);\n\n const viewOptions = this._viewOptions;\n\n const stage =\n (viewOptions.stage as unknown as Stage) ??\n createStage({\n width: this._width,\n height: this._height,\n renderStyle: viewOptions.renderStyle,\n viewBox: viewOptions.viewBox,\n dpr: viewOptions.dpr,\n canvas: viewOptions.renderCanvas,\n canvasControled: viewOptions.canvasControled,\n container: viewOptions.container,\n title: viewOptions.rendererTitle,\n beforeRender: viewOptions.beforeRender,\n afterRender: viewOptions.afterRender,\n disableDirtyBounds: true,\n autoRender: true,\n pluginList: viewOptions.pluginList,\n enableHtmlAttribute: viewOptions.enableHtmlAttribute,\n optimize: viewOptions.optimize,\n ticker: viewOptions.ticker,\n supportsTouchEvents: viewOptions.supportsTouchEvents,\n supportsPointerEvents: viewOptions.supportsPointerEvents,\n ReactDOM: viewOptions.ReactDOM,\n autoRefresh: viewOptions.autoRefresh\n });\n\n if (viewOptions.options3d?.enable) {\n stage.set3dOptions(viewOptions.options3d);\n }\n\n stage.enableIncrementalAutoRender();\n\n this._viewBox = viewOptions.viewBox;\n this._view.emit(HOOK_EVENT.AFTER_CREATE_VRENDER_STAGE);\n\n this._view.emit(HOOK_EVENT.BEFORE_CREATE_VRENDER_LAYER);\n const layer = viewOptions.layer ?? (stage.defaultLayer as ILayer);\n this._view.emit(HOOK_EVENT.AFTER_CREATE_VRENDER_LAYER);\n\n if (this._eventConfig?.drag && Factory.getStageEventPlugin('drag')) {\n // 允许 drag 事件\n this._dragController = new (Factory.getStageEventPlugin('drag'))(stage as unknown as IEventTarget) as DragNDrop;\n }\n if (this._eventConfig?.gesture && Factory.getStageEventPlugin('gesture')) {\n const gestureConfig = isObject(this._eventConfig.gesture) ? this._eventConfig.gesture : {};\n // 允许手势\n this._gestureController = new (Factory.getStageEventPlugin('gesture'))(\n stage as unknown as IEventTarget,\n gestureConfig\n ) as Gesture;\n }\n\n return {\n stage,\n layer\n };\n }\n\n private initStage() {\n if (!this._stage) {\n const { stage, layer } = this.createStage();\n\n this._stage = stage;\n this._layer = layer;\n\n const background = this._view.background();\n this.background(background);\n }\n }\n\n private handleAfterNextRender = () => {\n if (this._stage && !this._viewOptions.disableDirtyBounds) {\n this._stage.enableDirtyBounds();\n }\n\n this._view.emit(HOOK_EVENT.AFTER_VRENDER_DRAW);\n this._view.emit(HOOK_EVENT.AFTER_VRENDER_NEXT_RENDER);\n };\n}\n"]}
|
|
@@ -58,7 +58,8 @@ class GlyphElement extends element_1.Element {
|
|
|
58
58
|
encodeGraphic() {
|
|
59
59
|
this.coordinateTransformEncode(this.items);
|
|
60
60
|
const graphicAttributes = this.transformElementItems(this.items, this.mark.markType), isGraphicInit = !this.graphicItem;
|
|
61
|
-
this.graphicItem
|
|
61
|
+
this.graphicItem ? (this.graphicItem.clearStates(), this.graphicItem.states = {},
|
|
62
|
+
this.graphicItem.stateProxy = null) : this.initGraphicItem(), this.diffState === enums_1.DiffState.enter || isGraphicInit ? (this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(!0),
|
|
62
63
|
this.applyGraphicAttributes(graphicAttributes), this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(!1)) : this.applyGraphicAttributes(graphicAttributes),
|
|
63
64
|
this.diffState !== enums_1.DiffState.enter && this.diffState !== enums_1.DiffState.update || !this.states.length || (Object.values(this.glyphGraphicItems).forEach((graphicItem => {
|
|
64
65
|
graphicItem.states = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/glyph-element.ts"],"names":[],"mappings":";;;AAAA,6CAA8E;AAU9E,sDAAuF;AACvF,2CAAmE;AACnE,mCAAiE;AACjE,uCAAoC;AACpC,0CAAqD;AAGrD,MAAa,YAAa,SAAQ,iBAAO;IAQvC,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAC;QAqDJ,kBAAa,GAAG,CAAC,SAAiB,EAAE,UAAoB,EAAE,EAAE;;YACpE,MAAM,cAAc,GAAG,CAAC,IAAA,cAAK,EAAC,MAAA,IAAI,CAAC,oBAAoB,0CAAG,SAAS,CAAC,CAAC,CAAC;YACtE,MAAM,OAAO,GAAG,cAAc;gBAC5B,CAAC,iCACM,MAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAe,CAAC,MAAM,0CAAG,SAAS,CAAC,GACrD,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAE3C,CAAC,CAAC,MAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAe,CAAC,MAAM,0CAAG,SAAS,CAAC,CAAC;YAE1D,MAAM,oBAAoB,GAAG,EAG5B,CAAC;YAEF,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,oBAAoB,CAAC;aAC7B;YAED,IAAI,IAAA,mBAAU,EAAC,OAAO,CAAC,EAAE;gBACvB,oBAAoB,CAAC,UAAU,GAAI,OAAgC,CAAC,IAAI,CA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H,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;SAC/B;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAjZD,oCAiZC","file":"glyph-element.js","sourcesContent":["import { has, isNil, isBoolean, isFunction, isEqual } from '@visactor/vutils';\nimport type {\n IGlyphElement,\n IGlyphMark,\n MarkElementItem,\n MarkSpec,\n IGlyphMeta,\n MarkType,\n StateProxyEncodeSpec\n} from '../types';\nimport { cloneTransformAttributes, transformAttributes } from './attributes/transform';\nimport { BridgeElementKey, CollectionMarkType } from './constants';\nimport { DiffState, HOOK_EVENT, GrammarMarkType } from './enums';\nimport { Element } from './element';\nimport { invokeEncoderToItems } from './mark/encode';\nimport type { IGraphicAttribute, IGlyph } from '@visactor/vrender-core';\n\nexport class GlyphElement extends Element implements IGlyphElement {\n declare graphicItem: IGlyph;\n\n declare mark: IGlyphMark;\n protected glyphGraphicItems: { [markName: string]: any };\n\n private glyphMeta: IGlyphMeta;\n\n constructor(mark: IGlyphMark) {\n super(mark);\n this.glyphMeta = this.mark.getGlyphMeta();\n }\n\n getGlyphGraphicItems() {\n return this.glyphGraphicItems;\n }\n\n initGraphicItem(attributes: any = {}) {\n if (this.graphicItem) {\n return;\n }\n\n this.graphicItem = this.mark.addGraphicItem(attributes, this.groupKey) as IGlyph;\n this.graphicItem[BridgeElementKey] = this;\n this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(false);\n\n const glyphMarks = this.glyphMeta.getMarks();\n this.glyphGraphicItems = {};\n this.graphicItem.getSubGraphic().forEach((graphic: any) => {\n const markType = glyphMarks[graphic.name];\n this.glyphGraphicItems[graphic.name] = graphic;\n graphic.onBeforeAttributeUpdate = (attributes: any) => {\n // mark might be released\n if (!this.mark) {\n return attributes;\n }\n const graphicAttributes = transformAttributes(markType, attributes, this, graphic.name);\n return graphicAttributes;\n };\n });\n\n this.clearGraphicAttributes();\n }\n\n useStates(states: string[], hasAnimation?: boolean) {\n if (!this.graphicItem) {\n return false;\n }\n this.mark.emit(HOOK_EVENT.BEFORE_ELEMENT_STATE, { states }, this);\n\n this.states = states.slice();\n\n const stateAnimationEnable = isBoolean(hasAnimation) ? hasAnimation : this.hasStateAnimation();\n\n this.graphicItem.glyphStateProxy = this.getStateAttrs;\n this.graphicItem.useStates(this.states, stateAnimationEnable);\n\n this.mark.emit(HOOK_EVENT.AFTER_ELEMENT_STATE, { states }, this);\n\n return true;\n }\n\n protected getStateAttrs = (stateName: string, nextStates: string[]) => {\n const isRuntimeState = !isNil(this.runtimeStatesEncoder?.[stateName]);\n const encoder = isRuntimeState\n ? {\n ...(this.mark.getSpec() as MarkSpec).encode?.[stateName],\n ...this.runtimeStatesEncoder[stateName]\n }\n : (this.mark.getSpec() as MarkSpec).encode?.[stateName];\n\n const glyphStateAttributes = {} as {\n attributes: Partial<IGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n };\n\n if (!encoder) {\n return glyphStateAttributes;\n }\n\n if (isFunction(encoder)) {\n glyphStateAttributes.attributes = (encoder as StateProxyEncodeSpec)(this.getDatum(), this, stateName, nextStates);\n return glyphStateAttributes;\n }\n\n if (!isRuntimeState && this.graphicItem.glyphStates?.[stateName]) {\n return this.graphicItem.glyphStates[stateName];\n }\n\n if (encoder) {\n const item = this.items[0];\n const targetItems = [Object.assign({}, item, { nextAttrs: {} })];\n\n invokeEncoderToItems(this, targetItems, encoder, (this.mark as any).parameters());\n this.coordinateTransformEncode(targetItems);\n\n glyphStateAttributes.attributes = targetItems[0].nextAttrs;\n\n if (!this.graphicItem.glyphStates) {\n this.graphicItem.glyphStates = { [stateName]: glyphStateAttributes };\n } else if (!this.graphicItem.glyphStates[stateName]) {\n this.graphicItem.glyphStates[stateName] = glyphStateAttributes;\n }\n\n return glyphStateAttributes;\n }\n\n return glyphStateAttributes;\n };\n\n encodeGraphic() {\n this.coordinateTransformEncode(this.items);\n const graphicAttributes = this.transformElementItems(this.items, this.mark.markType);\n\n const isGraphicInit = !this.graphicItem;\n if (!this.graphicItem) {\n this.initGraphicItem();\n }\n\n if (this.diffState === DiffState.enter || isGraphicInit) {\n // apply default encoder when enter or graphic item is created\n this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(true);\n this.applyGraphicAttributes(graphicAttributes);\n this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(false);\n } else {\n this.applyGraphicAttributes(graphicAttributes);\n }\n\n if ((this.diffState === DiffState.enter || this.diffState === DiffState.update) && this.states.length) {\n Object.values(this.glyphGraphicItems).forEach(graphicItem => {\n // 更新数据流后,states计算不缓存\n graphicItem.states = {};\n });\n this.useStates(this.states);\n }\n\n // clear item attributes\n this.items.map(item => {\n item.nextAttrs = {};\n });\n }\n\n encodeCustom(nextAttrs?: any): { [markName: string]: any } {\n let customEncodeValues: { [markName: string]: any } = {};\n const channelEncoder = this.glyphMeta.getChannelEncoder();\n const functionEncoder = this.glyphMeta.getFunctionEncoder();\n\n if (functionEncoder) {\n customEncodeValues = functionEncoder.call(\n null,\n Object.assign({}, this.graphicItem?.attribute, nextAttrs),\n this.getDatum(),\n this,\n this.mark.getGlyphConfig()\n );\n }\n if (channelEncoder) {\n // TODO: maybe delete origin encode value?\n let allAttrs: any;\n Object.keys(channelEncoder).forEach(channel => {\n if (!isNil(nextAttrs[channel])) {\n if (!allAttrs) {\n allAttrs = Object.assign({}, this.graphicItem?.attribute, nextAttrs);\n }\n const encodeResult = channelEncoder[channel].call(\n null,\n channel,\n nextAttrs[channel],\n allAttrs,\n this.getDatum(),\n this,\n this.mark.getGlyphConfig()\n );\n Object.keys(encodeResult ?? {}).forEach(markName => {\n customEncodeValues[markName] = Object.assign(customEncodeValues[markName] ?? {}, encodeResult[markName]);\n });\n }\n });\n }\n return customEncodeValues;\n }\n\n private encodeDefault() {\n const defaultEncodeValues: { [markName: string]: any } = {};\n // apply default encode\n if (this.glyphMeta.getDefaultEncoder()) {\n const defaultEncodeResult = this.glyphMeta\n .getDefaultEncoder()\n .call(null, this.getDatum(), this, this.mark.getGlyphConfig());\n Object.assign(defaultEncodeValues, defaultEncodeResult);\n }\n return defaultEncodeValues;\n }\n\n private _onGlyphAttributeUpdate(first: boolean = false) {\n return (attributes: any) => {\n // mark might be released\n if (!this.mark) {\n return attributes;\n }\n const glyphMarks = this.glyphMeta.getMarks();\n\n const graphicAttributes = transformAttributes(this.mark.getAttributeTransforms(), attributes, this);\n\n // apply default encode\n const defaultEncodeValues = first ? this.encodeDefault() : null;\n // apply custom encode\n const customEncodeValues = this.encodeCustom(attributes);\n\n Object.keys(glyphMarks).forEach(markName => {\n const markType = glyphMarks[markName];\n const graphicItem = this.glyphGraphicItems[markName];\n const customAttributes = customEncodeValues?.[markName];\n const additionalAttributes = Object.assign({}, customAttributes);\n if (first) {\n // apply default attributes when visual channel is not set\n const defaultAttributes = defaultEncodeValues?.[markName];\n Object.keys(defaultAttributes ?? {}).forEach(key => {\n if (!has(this.items[0].nextAttrs, key) && !has(additionalAttributes, key)) {\n additionalAttributes[key] = defaultAttributes[key];\n }\n });\n }\n const glyphAttributes = Object.assign({}, cloneTransformAttributes(markType, attributes), additionalAttributes);\n const glyphItems = this._generateGlyphItems(markType, this.items, glyphAttributes);\n this.coordinateTransformEncode(glyphItems);\n const graphicAttributes = this.transformElementItems(glyphItems, markType);\n\n this.applyGlyphGraphicAttributes(graphicAttributes, markName, graphicItem);\n\n if (markType === GrammarMarkType.shape) {\n // FIXME: shape需要拿到原始数据进行编码,暂时把数据绑定到graphicItem上,看后续graphicItem是否需要支持数据绑定\n graphicItem.datum = glyphItems[0].datum;\n }\n });\n\n return graphicAttributes;\n };\n }\n\n private _generateGlyphItems(markType: MarkType, items: MarkElementItem[], additionalAttributes: any) {\n const glyphItems = items.map(item => Object.assign({}, item, { nextAttrs: additionalAttributes }));\n\n if ((CollectionMarkType as string[]).includes(markType) && this.mark.getSpec().enableSegments) {\n // segment mark require all items to apply additional attributes\n glyphItems.forEach((glyphItem, index) => {\n glyphItem.nextAttrs = Object.assign({}, items[index].nextAttrs, additionalAttributes);\n });\n }\n\n return glyphItems;\n }\n\n getGraphicAttribute(channel: string, prev: boolean = false, markName?: any) {\n if (!this.graphicItem) {\n return undefined;\n }\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName);\n if (prev && has(prevGraphicAttributes, channel)) {\n return prevGraphicAttributes[channel];\n }\n\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.attribute[channel];\n }\n\n setGraphicAttribute(channel: string, value: any, final: boolean = true, markName?: any) {\n if (!this.graphicItem) {\n return;\n }\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName);\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName);\n\n if (final) {\n finalGraphicAttributes[channel] = value;\n }\n if (!has(prevGraphicAttributes, channel)) {\n prevGraphicAttributes[channel] = graphicItem.attribute[channel];\n }\n\n graphicItem.setAttribute(channel, value);\n }\n\n setGraphicAttributes(attributes: { [channel: string]: any }, final: boolean = true, markName?: any) {\n if (!this.graphicItem) {\n return;\n }\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName);\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName);\n\n Object.keys(attributes).forEach(key => {\n if (final) {\n finalGraphicAttributes[key] = attributes[key];\n }\n if (!has(prevGraphicAttributes, key)) {\n prevGraphicAttributes[key] = graphicItem.attribute[key];\n }\n });\n\n graphicItem.setAttributes(attributes);\n }\n\n protected diffAttributes(graphicAttributes: { [channel: string]: any }, markName?: string) {\n const diffResult = {};\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName);\n for (const key in graphicAttributes) {\n if (!has(finalGraphicAttributes, key) || !isEqual(finalGraphicAttributes[key], graphicAttributes[key])) {\n diffResult[key] = graphicAttributes[key];\n }\n }\n return diffResult;\n }\n\n protected applyGlyphGraphicAttributes(graphicAttributes: any, markName: string, graphicItem: any): void {\n if (this.mark.needAnimate()) {\n // If mark need animate, diff attributes.\n const nextGraphicAttributes = this.diffAttributes(graphicAttributes, markName);\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName) ?? {};\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName) ?? {};\n Object.keys(nextGraphicAttributes).forEach(channel => {\n prevGraphicAttributes[channel] = graphicItem.attribute[channel];\n finalGraphicAttributes[channel] = nextGraphicAttributes[channel];\n });\n this.setNextGraphicAttributes(nextGraphicAttributes, markName);\n this.setPrevGraphicAttributes(prevGraphicAttributes, markName);\n this.setFinalGraphicAttributes(finalGraphicAttributes, markName);\n\n // Apply next attributes to current graphic item immediately.\n // Scene graph tree should be handled like no animation exists in dataflow procedure.\n graphicItem.setAttributes(nextGraphicAttributes);\n } else {\n graphicItem.setAttributes(graphicAttributes);\n }\n }\n\n getFinalGraphicAttributes(markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.finalAttrs;\n }\n\n protected setFinalGraphicAttributes(attributes: { [channel: string]: any }, markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n graphicItem.finalAttrs = attributes;\n }\n\n getPrevGraphicAttributes(markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.prevAttrs;\n }\n\n protected setPrevGraphicAttributes(attributes: { [channel: string]: any }, markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n graphicItem.prevAttrs = attributes;\n }\n\n getNextGraphicAttributes(markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.nextAttrs;\n }\n\n protected setNextGraphicAttributes(attributes: { [channel: string]: any }, markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n graphicItem.nextAttrs = attributes;\n }\n\n clearChangedGraphicAttributes() {\n this.setPrevGraphicAttributes(null);\n this.setNextGraphicAttributes(null);\n Object.keys(this.glyphGraphicItems).forEach(markName => {\n this.setPrevGraphicAttributes(null, markName);\n this.setNextGraphicAttributes(null, markName);\n });\n }\n\n clearGraphicAttributes() {\n this.setPrevGraphicAttributes(null);\n this.setNextGraphicAttributes(null);\n this.setFinalGraphicAttributes(null);\n Object.keys(this.glyphGraphicItems).forEach(markName => {\n this.setPrevGraphicAttributes(null, markName);\n this.setNextGraphicAttributes(null, markName);\n this.setFinalGraphicAttributes(null, markName);\n });\n }\n\n remove() {\n this.glyphGraphicItems = null;\n super.remove();\n }\n\n release() {\n if (this.glyphGraphicItems) {\n Object.values(this.glyphGraphicItems).forEach(graphicItem => {\n graphicItem[BridgeElementKey] = null;\n });\n this.glyphGraphicItems = null;\n }\n super.release();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/glyph-element.ts"],"names":[],"mappings":";;;AAAA,6CAA8E;AAU9E,sDAAuF;AACvF,2CAAmE;AACnE,mCAAiE;AACjE,uCAAoC;AACpC,0CAAqD;AAGrD,MAAa,YAAa,SAAQ,iBAAO;IAQvC,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAC;QAqDJ,kBAAa,GAAG,CAAC,SAAiB,EAAE,UAAoB,EAAE,EAAE;;YACpE,MAAM,cAAc,GAAG,CAAC,IAAA,cAAK,EAAC,MAAA,IAAI,CAAC,oBAAoB,0CAAG,SAAS,CAAC,CAAC,CAAC;YAEtE,MAAM,OAAO,GAAG,cAAc;gBAC5B,CAAC,iCACM,MAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAe,CAAC,MAAM,0CAAG,SAAS,CAAC,GACrD,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAE3C,CAAC,CAAC,MAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAe,CAAC,MAAM,0CAAG,SAAS,CAAC,CAAC;YAE1D,MAAM,oBAAoB,GAAG,EAG5B,CAAC;YAEF,IAAI,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IAED,MAAM;QACJ,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBAC1D,WAAW,CAAC,4BAAgB,CAAC,GAAG,IAAI,CAAC;YACvC,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;SAC/B;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAvZD,oCAuZC","file":"glyph-element.js","sourcesContent":["import { has, isNil, isBoolean, isFunction, isEqual } from '@visactor/vutils';\nimport type {\n IGlyphElement,\n IGlyphMark,\n MarkElementItem,\n MarkSpec,\n IGlyphMeta,\n MarkType,\n StateProxyEncodeSpec\n} from '../types';\nimport { cloneTransformAttributes, transformAttributes } from './attributes/transform';\nimport { BridgeElementKey, CollectionMarkType } from './constants';\nimport { DiffState, HOOK_EVENT, GrammarMarkType } from './enums';\nimport { Element } from './element';\nimport { invokeEncoderToItems } from './mark/encode';\nimport type { IGraphicAttribute, IGlyph } from '@visactor/vrender-core';\n\nexport class GlyphElement extends Element implements IGlyphElement {\n declare graphicItem: IGlyph;\n\n declare mark: IGlyphMark;\n protected glyphGraphicItems: { [markName: string]: any };\n\n private glyphMeta: IGlyphMeta;\n\n constructor(mark: IGlyphMark) {\n super(mark);\n this.glyphMeta = this.mark.getGlyphMeta();\n }\n\n getGlyphGraphicItems() {\n return this.glyphGraphicItems;\n }\n\n initGraphicItem(attributes: any = {}) {\n if (this.graphicItem) {\n return;\n }\n\n this.graphicItem = this.mark.addGraphicItem(attributes, this.groupKey) as IGlyph;\n this.graphicItem[BridgeElementKey] = this;\n this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(false);\n\n const glyphMarks = this.glyphMeta.getMarks();\n this.glyphGraphicItems = {};\n this.graphicItem.getSubGraphic().forEach((graphic: any) => {\n const markType = glyphMarks[graphic.name];\n this.glyphGraphicItems[graphic.name] = graphic;\n graphic.onBeforeAttributeUpdate = (attributes: any) => {\n // mark might be released\n if (!this.mark) {\n return attributes;\n }\n const graphicAttributes = transformAttributes(markType, attributes, this, graphic.name);\n return graphicAttributes;\n };\n });\n\n this.clearGraphicAttributes();\n }\n\n useStates(states: string[], hasAnimation?: boolean) {\n if (!this.graphicItem) {\n return false;\n }\n this.mark.emit(HOOK_EVENT.BEFORE_ELEMENT_STATE, { states }, this);\n\n this.states = states.slice();\n\n const stateAnimationEnable = isBoolean(hasAnimation) ? hasAnimation : this.hasStateAnimation();\n\n this.graphicItem.glyphStateProxy = this.getStateAttrs;\n this.graphicItem.useStates(this.states, stateAnimationEnable);\n\n this.mark.emit(HOOK_EVENT.AFTER_ELEMENT_STATE, { states }, this);\n\n return true;\n }\n\n protected getStateAttrs = (stateName: string, nextStates: string[]) => {\n const isRuntimeState = !isNil(this.runtimeStatesEncoder?.[stateName]);\n\n const encoder = isRuntimeState\n ? {\n ...(this.mark.getSpec() as MarkSpec).encode?.[stateName],\n ...this.runtimeStatesEncoder[stateName]\n }\n : (this.mark.getSpec() as MarkSpec).encode?.[stateName];\n\n const glyphStateAttributes = {} as {\n attributes: Partial<IGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n };\n\n if (!encoder) {\n return glyphStateAttributes;\n }\n\n if (isFunction(encoder)) {\n glyphStateAttributes.attributes = (encoder as StateProxyEncodeSpec)(this.getDatum(), this, stateName, nextStates);\n return glyphStateAttributes;\n }\n\n if (!isRuntimeState && this.graphicItem.glyphStates?.[stateName]) {\n return this.graphicItem.glyphStates[stateName];\n }\n\n if (encoder) {\n const item = this.items[0];\n const targetItems = [Object.assign({}, item, { nextAttrs: {} })];\n\n invokeEncoderToItems(this, targetItems, encoder, (this.mark as any).parameters());\n this.coordinateTransformEncode(targetItems);\n\n glyphStateAttributes.attributes = targetItems[0].nextAttrs;\n\n if (!this.graphicItem.glyphStates) {\n this.graphicItem.glyphStates = { [stateName]: glyphStateAttributes };\n } else if (!this.graphicItem.glyphStates[stateName]) {\n this.graphicItem.glyphStates[stateName] = glyphStateAttributes;\n }\n\n return glyphStateAttributes;\n }\n\n return glyphStateAttributes;\n };\n\n encodeGraphic() {\n this.coordinateTransformEncode(this.items);\n const graphicAttributes = this.transformElementItems(this.items, this.mark.markType);\n\n const isGraphicInit = !this.graphicItem;\n if (!this.graphicItem) {\n this.initGraphicItem();\n } else {\n this.graphicItem.clearStates();\n // 更新数据流后,states计算不缓存\n this.graphicItem.states = {};\n this.graphicItem.stateProxy = null;\n }\n\n if (this.diffState === DiffState.enter || isGraphicInit) {\n // apply default encoder when enter or graphic item is created\n this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(true);\n this.applyGraphicAttributes(graphicAttributes);\n this.graphicItem.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(false);\n } else {\n this.applyGraphicAttributes(graphicAttributes);\n }\n\n if ((this.diffState === DiffState.enter || this.diffState === DiffState.update) && this.states.length) {\n Object.values(this.glyphGraphicItems).forEach(graphicItem => {\n // 更新数据流后,states计算不缓存\n graphicItem.states = {};\n });\n this.useStates(this.states);\n }\n\n // clear item attributes\n this.items.map(item => {\n item.nextAttrs = {};\n });\n }\n\n encodeCustom(nextAttrs?: any): { [markName: string]: any } {\n let customEncodeValues: { [markName: string]: any } = {};\n const channelEncoder = this.glyphMeta.getChannelEncoder();\n const functionEncoder = this.glyphMeta.getFunctionEncoder();\n\n if (functionEncoder) {\n customEncodeValues = functionEncoder.call(\n null,\n Object.assign({}, this.graphicItem?.attribute, nextAttrs),\n this.getDatum(),\n this,\n this.mark.getGlyphConfig()\n );\n }\n if (channelEncoder) {\n // TODO: maybe delete origin encode value?\n let allAttrs: any;\n Object.keys(channelEncoder).forEach(channel => {\n if (!isNil(nextAttrs[channel])) {\n if (!allAttrs) {\n allAttrs = Object.assign({}, this.graphicItem?.attribute, nextAttrs);\n }\n const encodeResult = channelEncoder[channel].call(\n null,\n channel,\n nextAttrs[channel],\n allAttrs,\n this.getDatum(),\n this,\n this.mark.getGlyphConfig()\n );\n Object.keys(encodeResult ?? {}).forEach(markName => {\n customEncodeValues[markName] = Object.assign(customEncodeValues[markName] ?? {}, encodeResult[markName]);\n });\n }\n });\n }\n return customEncodeValues;\n }\n\n private encodeDefault() {\n const defaultEncodeValues: { [markName: string]: any } = {};\n // apply default encode\n if (this.glyphMeta.getDefaultEncoder()) {\n const defaultEncodeResult = this.glyphMeta\n .getDefaultEncoder()\n .call(null, this.getDatum(), this, this.mark.getGlyphConfig());\n Object.assign(defaultEncodeValues, defaultEncodeResult);\n }\n return defaultEncodeValues;\n }\n\n private _onGlyphAttributeUpdate(first: boolean = false) {\n return (attributes: any) => {\n // mark might be released\n if (!this.mark) {\n return attributes;\n }\n const glyphMarks = this.glyphMeta.getMarks();\n\n const graphicAttributes = transformAttributes(this.mark.getAttributeTransforms(), attributes, this);\n\n // apply default encode\n const defaultEncodeValues = first ? this.encodeDefault() : null;\n // apply custom encode\n const customEncodeValues = this.encodeCustom(attributes);\n\n Object.keys(glyphMarks).forEach(markName => {\n const markType = glyphMarks[markName];\n const graphicItem = this.glyphGraphicItems[markName];\n const customAttributes = customEncodeValues?.[markName];\n const additionalAttributes = Object.assign({}, customAttributes);\n if (first) {\n // apply default attributes when visual channel is not set\n const defaultAttributes = defaultEncodeValues?.[markName];\n Object.keys(defaultAttributes ?? {}).forEach(key => {\n if (!has(this.items[0].nextAttrs, key) && !has(additionalAttributes, key)) {\n additionalAttributes[key] = defaultAttributes[key];\n }\n });\n }\n const glyphAttributes = Object.assign({}, cloneTransformAttributes(markType, attributes), additionalAttributes);\n const glyphItems = this._generateGlyphItems(markType, this.items, glyphAttributes);\n this.coordinateTransformEncode(glyphItems);\n const graphicAttributes = this.transformElementItems(glyphItems, markType);\n\n this.applyGlyphGraphicAttributes(graphicAttributes, markName, graphicItem);\n\n if (markType === GrammarMarkType.shape) {\n // FIXME: shape需要拿到原始数据进行编码,暂时把数据绑定到graphicItem上,看后续graphicItem是否需要支持数据绑定\n graphicItem.datum = glyphItems[0].datum;\n }\n });\n\n return graphicAttributes;\n };\n }\n\n private _generateGlyphItems(markType: MarkType, items: MarkElementItem[], additionalAttributes: any) {\n const glyphItems = items.map(item => Object.assign({}, item, { nextAttrs: additionalAttributes }));\n\n if ((CollectionMarkType as string[]).includes(markType) && this.mark.getSpec().enableSegments) {\n // segment mark require all items to apply additional attributes\n glyphItems.forEach((glyphItem, index) => {\n glyphItem.nextAttrs = Object.assign({}, items[index].nextAttrs, additionalAttributes);\n });\n }\n\n return glyphItems;\n }\n\n getGraphicAttribute(channel: string, prev: boolean = false, markName?: any) {\n if (!this.graphicItem) {\n return undefined;\n }\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName);\n if (prev && has(prevGraphicAttributes, channel)) {\n return prevGraphicAttributes[channel];\n }\n\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.attribute[channel];\n }\n\n setGraphicAttribute(channel: string, value: any, final: boolean = true, markName?: any) {\n if (!this.graphicItem) {\n return;\n }\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName);\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName);\n\n if (final) {\n finalGraphicAttributes[channel] = value;\n }\n if (!has(prevGraphicAttributes, channel)) {\n prevGraphicAttributes[channel] = graphicItem.attribute[channel];\n }\n\n graphicItem.setAttribute(channel, value);\n }\n\n setGraphicAttributes(attributes: { [channel: string]: any }, final: boolean = true, markName?: any) {\n if (!this.graphicItem) {\n return;\n }\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName);\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName);\n\n Object.keys(attributes).forEach(key => {\n if (final) {\n finalGraphicAttributes[key] = attributes[key];\n }\n if (!has(prevGraphicAttributes, key)) {\n prevGraphicAttributes[key] = graphicItem.attribute[key];\n }\n });\n\n graphicItem.setAttributes(attributes);\n }\n\n protected diffAttributes(graphicAttributes: { [channel: string]: any }, markName?: string) {\n const diffResult = {};\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName);\n for (const key in graphicAttributes) {\n if (!has(finalGraphicAttributes, key) || !isEqual(finalGraphicAttributes[key], graphicAttributes[key])) {\n diffResult[key] = graphicAttributes[key];\n }\n }\n return diffResult;\n }\n\n protected applyGlyphGraphicAttributes(graphicAttributes: any, markName: string, graphicItem: any): void {\n if (this.mark.needAnimate()) {\n // If mark need animate, diff attributes.\n const nextGraphicAttributes = this.diffAttributes(graphicAttributes, markName);\n const prevGraphicAttributes = this.getPrevGraphicAttributes(markName) ?? {};\n const finalGraphicAttributes = this.getFinalGraphicAttributes(markName) ?? {};\n Object.keys(nextGraphicAttributes).forEach(channel => {\n prevGraphicAttributes[channel] = graphicItem.attribute[channel];\n finalGraphicAttributes[channel] = nextGraphicAttributes[channel];\n });\n this.setNextGraphicAttributes(nextGraphicAttributes, markName);\n this.setPrevGraphicAttributes(prevGraphicAttributes, markName);\n this.setFinalGraphicAttributes(finalGraphicAttributes, markName);\n\n // Apply next attributes to current graphic item immediately.\n // Scene graph tree should be handled like no animation exists in dataflow procedure.\n graphicItem.setAttributes(nextGraphicAttributes);\n } else {\n graphicItem.setAttributes(graphicAttributes);\n }\n }\n\n getFinalGraphicAttributes(markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.finalAttrs;\n }\n\n protected setFinalGraphicAttributes(attributes: { [channel: string]: any }, markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n graphicItem.finalAttrs = attributes;\n }\n\n getPrevGraphicAttributes(markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.prevAttrs;\n }\n\n protected setPrevGraphicAttributes(attributes: { [channel: string]: any }, markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n graphicItem.prevAttrs = attributes;\n }\n\n getNextGraphicAttributes(markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n return graphicItem.nextAttrs;\n }\n\n protected setNextGraphicAttributes(attributes: { [channel: string]: any }, markName?: string) {\n const graphicItem = markName ? this.glyphGraphicItems[markName] : this.graphicItem;\n graphicItem.nextAttrs = attributes;\n }\n\n clearChangedGraphicAttributes() {\n this.setPrevGraphicAttributes(null);\n this.setNextGraphicAttributes(null);\n Object.keys(this.glyphGraphicItems).forEach(markName => {\n this.setPrevGraphicAttributes(null, markName);\n this.setNextGraphicAttributes(null, markName);\n });\n }\n\n clearGraphicAttributes() {\n this.setPrevGraphicAttributes(null);\n this.setNextGraphicAttributes(null);\n this.setFinalGraphicAttributes(null);\n Object.keys(this.glyphGraphicItems).forEach(markName => {\n this.setPrevGraphicAttributes(null, markName);\n this.setNextGraphicAttributes(null, markName);\n this.setFinalGraphicAttributes(null, markName);\n });\n }\n\n remove() {\n this.glyphGraphicItems = null;\n super.remove();\n }\n\n release() {\n if (this.glyphGraphicItems) {\n Object.values(this.glyphGraphicItems).forEach(graphicItem => {\n graphicItem[BridgeElementKey] = null;\n });\n this.glyphGraphicItems = null;\n }\n super.release();\n }\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.registerAnimate = exports.registerGesturePlugin = exports.registerDragPlugin = exports.GlyphMark = exports.registerGlyphMark = exports.defaultDoLayout = exports.registerDefaultLayout = exports.vglobal = exports.ThemeManager = exports.registerViewMorphAPI = exports.registerViewEventsAPI = exports.SIGNAL_VIEW_BOX = exports.SIGNAL_WIDTH = exports.SIGNAL_VIEW_WIDTH = exports.SIGNAL_VIEW_HEIGHT = exports.SIGNAL_PADDING = exports.SIGNAL_HEIGHT = exports.SIGNAL_AUTOFIT = exports.Factory = exports.GrammarBase = exports.invokeFunctionType = exports.parseFunctionType = exports.registerCoordinate = exports.Coordinate = exports.registerScale = exports.Scale = exports.View = exports.version = void 0,
|
|
21
|
-
exports.version = "0.14.
|
|
21
|
+
exports.version = "0.14.17", __exportStar(require("./graph"), exports), __exportStar(require("./interactions"), exports);
|
|
22
22
|
|
|
23
23
|
var view_1 = require("./view");
|
|
24
24
|
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,SAAS,CAAC;AAEjC,0CAAwB;AAExB,iDAA+B;AAE/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,sCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC7B,gDAAmE;AAA1D,wGAAA,UAAU,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AACvC,qCAAqE;AAA5D,yGAAA,iBAAiB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9C,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,8CAQ0B;AAPxB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAEjB,4DAAgE;AAAvD,yHAAA,qBAAqB,OAAA;AAC9B,4DAA+D;AAAtD,wHAAA,oBAAoB,OAAA;AAE7B,uDAAqD;AAA5C,6GAAA,YAAY,OAAA;AAErB,0CAAwB;AACxB,8CAA4B;AAC5B,+CAA6B;AAC7B,8DAA4C;AAE5C,uDAAiD;AAAxC,uGAAA,OAAO,OAAA;AAChB,wCAAsB;AACtB,iDAA+B;AAC/B,wDAAsC;AACtC,4DAA0C;AAC1C,uDAAqC;AACrC,gDAA+E;AAAtE,+GAAA,qBAAqB,OAAA;AAAE,yGAAA,eAAe,OAAA;AAC/C,sCAA4D;AAAnD,0GAAA,iBAAiB,OAAA;AAAE,kGAAA,SAAS,OAAA;AAErC,yDAA4D;AAC5D,4CAAyC;AAElC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,iBAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,wBAAS,CAAC,CAAC;AACtD,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEK,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,iBAAO,CAAC,wBAAwB,CAAC,SAAS,EAAE,sBAAO,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AAEF,kEAAmE;AACnE,kEAAmE;AAE5D,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,IAAA,2CAAsB,GAAE,CAAC;IACzB,IAAA,2CAAsB,GAAE,CAAC;AAC3B,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.14.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,SAAS,CAAC;AAEjC,0CAAwB;AAExB,iDAA+B;AAE/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,sCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC7B,gDAAmE;AAA1D,wGAAA,UAAU,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AACvC,qCAA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GAAE,CAAC;IACzB,IAAA,2CAAsB,GAAE,CAAC;AAC3B,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.14.17\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\nexport { registerViewEventsAPI } from './view/view-event-mixin';\nexport { registerViewMorphAPI } from './view/view-morph-mixin';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\nexport { registerDefaultLayout, defaultDoLayout } from './graph/layout/layout';\nexport { registerGlyphMark, GlyphMark } from './view/glyph';\n\nimport { DragNDrop, Gesture } from '@visactor/vrender-kits';\nimport { Factory } from './core/factory';\n\nexport const registerDragPlugin = () => {\n Factory.registerStageEventPlugin('drag', DragNDrop);\n};\n\nexport const registerGesturePlugin = () => {\n Factory.registerStageEventPlugin('gesture', Gesture);\n};\n\nimport { registerViewAnimateAPI } from './view/view-animate-mixin';\nimport { registerMarkAnimateAPI } from './view/mark-animate-mixin';\n\nexport const registerAnimate = () => {\n registerViewAnimateAPI();\n registerMarkAnimateAPI();\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interact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BACJ;qBAAM;oBACL,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;iBAC7E;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAiC;IAEvC,CAAC;IAED,KAAK,CAAC,OAAkC;IAExC,CAAC;IAES,aAAa,CAAC,IAA0C,EAAE,MAAW;QAC7E,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;QAE/C,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAC5C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC9B;aAAM,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC9B;aAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YACrD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SAC/B;aAAM,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YAC/C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC5B;IACH,CAAC;CACF;AA/FD,0CA+FC","file":"base.js","sourcesContent":["import { array, isArray, isNil, isString, isValid } from '@visactor/vutils';\nimport type {\n IBaseInteractionOptions,\n IElement,\n IGlyphElement,\n IGrammarBase,\n IView,\n InteractionEventHandler\n} from '../types';\n\nexport abstract class BaseInteraction<T extends IBaseInteractionOptions> {\n readonly view: IView;\n\n options: T;\n\n type: string;\n\n constructor(view: IView, options: T) {\n this.view = view;\n this.depend(options?.dependency);\n }\n\n references: Map<IGrammarBase, number> = new Map();\n\n protected abstract getEvents(): Array<{ type: string | string[]; handler: InteractionEventHandler }>;\n\n getStartState(): string {\n return null;\n }\n\n depend(grammar: IGrammarBase[] | IGrammarBase | string[] | string) {\n this.references.clear();\n array(grammar)\n .map(grammar => (isString(grammar) ? this.view.getGrammarById(grammar) : grammar))\n .filter(ref => !isNil(ref))\n .forEach(ref => {\n this.references.set(ref, (this.references.get(ref) ?? 0) + 1);\n });\n }\n\n parameters() {\n const params: any = {};\n this.references.forEach((count, ref) => {\n // upstream reference with no valid id will not be recorded in parameters\n if (isValid(ref.id())) {\n params[ref.id() as string] = ref.output();\n }\n });\n return params;\n }\n\n bind() {\n const events = this.getEvents();\n\n (events ?? []).forEach(evt => {\n if (evt.type && evt.handler) {\n if (isArray(evt.type)) {\n evt.type.forEach(evtType => {\n evtType && evtType !== 'none' && this.view.addEventListener(evtType, evt.handler);\n });\n } else {\n evt.type !== 'none' && this.view.addEventListener(evt.type, evt.handler);\n }\n }\n });\n }\n\n unbind() {\n // unbind events\n const events = this.getEvents();\n\n (events ?? []).forEach(evt => {\n if (evt.type && evt.handler) {\n if (isArray(evt.type)) {\n evt.type.forEach(evtType => {\n evtType && evtType !== 'none' && this.view.removeEventListener(evtType, evt.handler);\n });\n } else {\n evt.type !== 'none' && this.view.removeEventListener(evt.type, evt.handler);\n }\n }\n });\n }\n\n start(element: IElement | IGlyphElement) {\n // do nothing\n }\n\n reset(element?: IElement | IGlyphElement) {\n // do
|
|
1
|
+
{"version":3,"sources":["../src/interactions/base.ts"],"names":[],"mappings":";;;AAAA,6CAA4E;AAU5E,MAAsB,eAAe;IAOnC,YAAY,IAAW,EAAE,OAAU;QAKnC,eAAU,GAA8B,IAAI,GAAG,EAAE,CAAC;QAJhD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP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AED,KAAK,CAAC,OAAkC;IAExC,CAAC;IAES,aAAa,CAAC,IAA0C,EAAE,MAAW;QAC7E,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;QAE/C,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAC5C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC9B;aAAM,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC9B;aAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YACrD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SAC/B;aAAM,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YAC/C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC5B;IACH,CAAC;CACF;AA/FD,0CA+FC","file":"base.js","sourcesContent":["import { array, isArray, isNil, isString, isValid } from '@visactor/vutils';\nimport type {\n IBaseInteractionOptions,\n IElement,\n IGlyphElement,\n IGrammarBase,\n IView,\n InteractionEventHandler\n} from '../types';\n\nexport abstract class BaseInteraction<T extends IBaseInteractionOptions> {\n readonly view: IView;\n\n options: T;\n\n type: string;\n\n constructor(view: IView, options: T) {\n this.view = view;\n this.depend(options?.dependency);\n }\n\n references: Map<IGrammarBase, number> = new Map();\n\n protected abstract getEvents(): Array<{ type: string | string[]; handler: InteractionEventHandler }>;\n\n getStartState(): string {\n return null;\n }\n\n depend(grammar: IGrammarBase[] | IGrammarBase | string[] | string) {\n this.references.clear();\n array(grammar)\n .map(grammar => (isString(grammar) ? this.view.getGrammarById(grammar) : grammar))\n .filter(ref => !isNil(ref))\n .forEach(ref => {\n this.references.set(ref, (this.references.get(ref) ?? 0) + 1);\n });\n }\n\n parameters() {\n const params: any = {};\n this.references.forEach((count, ref) => {\n // upstream reference with no valid id will not be recorded in parameters\n if (isValid(ref.id())) {\n params[ref.id() as string] = ref.output();\n }\n });\n return params;\n }\n\n bind() {\n const events = this.getEvents();\n\n (events ?? []).forEach(evt => {\n if (evt.type && evt.handler) {\n if (isArray(evt.type)) {\n evt.type.forEach(evtType => {\n evtType && evtType !== 'none' && this.view.addEventListener(evtType, evt.handler);\n });\n } else {\n evt.type !== 'none' && this.view.addEventListener(evt.type, evt.handler);\n }\n }\n });\n }\n\n unbind() {\n // unbind events\n const events = this.getEvents();\n\n (events ?? []).forEach(evt => {\n if (evt.type && evt.handler) {\n if (isArray(evt.type)) {\n evt.type.forEach(evtType => {\n evtType && evtType !== 'none' && this.view.removeEventListener(evtType, evt.handler);\n });\n } else {\n evt.type !== 'none' && this.view.removeEventListener(evt.type, evt.handler);\n }\n }\n });\n }\n\n start(element: IElement | IGlyphElement) {\n // do nothing\n }\n\n reset(element?: IElement | IGlyphElement) {\n // do nothing\n }\n\n protected dispatchEvent(type: 'start' | 'reset' | 'update' | 'end', params: any) {\n this.view.emit(`${this.type}:${type}`, params);\n\n if (type === 'start' && this.options.onStart) {\n this.options.onStart(params);\n } else if (type === 'reset' && this.options.onReset) {\n this.options.onReset(params);\n } else if (type === 'update' && this.options.onUpdate) {\n this.options.onUpdate(params);\n } else if (type === 'end' && this.options.onEnd) {\n this.options.onEnd(params);\n }\n }\n}\n"]}
|
|
@@ -14,7 +14,8 @@ export declare class ElementActiveByLegend extends BaseInteraction<ElementActive
|
|
|
14
14
|
}[];
|
|
15
15
|
getStartState(): string;
|
|
16
16
|
start(element: IElement | IGlyphElement | string): void;
|
|
17
|
-
|
|
17
|
+
resetAll(): void;
|
|
18
|
+
reset(element?: InteractionEvent['element']): void;
|
|
18
19
|
handleStart: (e: InteractionEvent) => void;
|
|
19
20
|
handleReset: (e: InteractionEvent) => void;
|
|
20
21
|
}
|
|
@@ -12,7 +12,7 @@ class ElementActiveByLegend extends base_1.BaseInteraction {
|
|
|
12
12
|
var _a, _b;
|
|
13
13
|
this.start(null === (_b = null === (_a = e.detail) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b.id);
|
|
14
14
|
}, this.handleReset = e => {
|
|
15
|
-
this.
|
|
15
|
+
this.resetAll();
|
|
16
16
|
}, this.options = Object.assign({}, ElementActiveByLegend.defaultOptions, options),
|
|
17
17
|
this._marks = view.getMarksBySelector(this.options.selector);
|
|
18
18
|
}
|
|
@@ -38,13 +38,16 @@ class ElementActiveByLegend extends base_1.BaseInteraction {
|
|
|
38
38
|
}));
|
|
39
39
|
}));
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
resetAll() {
|
|
42
42
|
this._marks.forEach((mark => {
|
|
43
43
|
mark.elements.forEach((el => {
|
|
44
44
|
el.removeState(this.options.state);
|
|
45
45
|
}));
|
|
46
46
|
}));
|
|
47
47
|
}
|
|
48
|
+
reset(element) {
|
|
49
|
+
element ? this._marks && this._marks.includes(element.mark) && element.removeState(this.options.state) : this.resetAll();
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
exports.ElementActiveByLegend = ElementActiveByLegend, ElementActiveByLegend.type = "element-active-by-legend",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/element-active-by-legend.ts"],"names":[],"mappings":";;;AAAA,0CAAsD;AAEtD,iCAAyC;AACzC,qEAA2D;AAC3D,6CAAyC;AACzC,mCAA8C;AAE9C,MAAa,qBAAsB,SAAQ,sBAA6C;IAWtF,YAAY,IAAW,EAAE,OAAsC;QAC7D,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAVvB,SAAI,GAAW,qBAAqB,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/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type { ElementActiveByLegendOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { LegendEvent } from '@visactor/vrender-components';\nimport { isNil } from '@visactor/vutils';\nimport { generateFilterValue } from './utils';\n\nexport class ElementActiveByLegend extends BaseInteraction<ElementActiveByLegendOptions> {\n static type: string = 'element-active-by-legend';\n type: string = ElementActiveByLegend.type;\n\n static defaultOptions: ElementActiveByLegendOptions = {\n state: InteractionStateEnum.active,\n filterType: 'groupKey'\n };\n options: ElementActiveByLegendOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementActiveByLegendOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementActiveByLegend.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: LegendEvent.legendItemHover,\n handler: this.handleStart\n },\n {\n type: LegendEvent.legendItemUnHover,\n handler: this.handleReset\n }\n ];\n }\n\n getStartState(): string {\n return this.options.state;\n }\n\n start(element: IElement | IGlyphElement | string) {\n const itemKey = element;\n\n if (isNil(itemKey)) {\n return;\n }\n\n const filterValue = generateFilterValue(this.options);\n\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isActive = filterValue(el) === itemKey;\n\n if (isActive) {\n el.addState(this.options.state);\n } else {\n el.removeState(this.options.state);\n }\n });\n });\n }\n\n resetAll() {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n el.removeState(this.options.state);\n });\n });\n }\n\n reset(element?: InteractionEvent['element']) {\n if (element) {\n if (this._marks && this._marks.includes(element.mark)) {\n element.removeState(this.options.state);\n }\n } else {\n this.resetAll();\n }\n }\n\n handleStart = (e: InteractionEvent) => {\n this.start(e.detail?.data?.id);\n };\n\n handleReset = (e: InteractionEvent) => {\n this.resetAll();\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementActiveOptions, IMark, IView, InteractionEvent } from '../types';
|
|
1
|
+
import type { ElementActiveOptions, IElement, IMark, IView, InteractionEvent } from '../types';
|
|
2
2
|
import { BaseInteraction } from './base';
|
|
3
3
|
export declare class ElementActive extends BaseInteraction<ElementActiveOptions> {
|
|
4
4
|
static type: string;
|
|
@@ -6,6 +6,7 @@ export declare class ElementActive extends BaseInteraction<ElementActiveOptions>
|
|
|
6
6
|
static defaultOptions: ElementActiveOptions;
|
|
7
7
|
options: ElementActiveOptions;
|
|
8
8
|
protected _marks?: IMark[];
|
|
9
|
+
protected _prevActiveElement?: IElement;
|
|
9
10
|
constructor(view: IView, options?: ElementActiveOptions);
|
|
10
11
|
protected getEvents(): {
|
|
11
12
|
type: "none" | import("../types").EventType | import("../types").EventType[];
|
|
@@ -13,7 +14,7 @@ export declare class ElementActive extends BaseInteraction<ElementActiveOptions>
|
|
|
13
14
|
}[];
|
|
14
15
|
getStartState(): string;
|
|
15
16
|
start(element: InteractionEvent['element']): void;
|
|
16
|
-
reset(element
|
|
17
|
+
reset(element?: InteractionEvent['element']): void;
|
|
17
18
|
handleStart: (e: InteractionEvent) => void;
|
|
18
19
|
handleReset: (e: InteractionEvent) => void;
|
|
19
20
|
}
|
|
@@ -27,10 +27,12 @@ class ElementActive extends base_1.BaseInteraction {
|
|
|
27
27
|
return this.options.state;
|
|
28
28
|
}
|
|
29
29
|
start(element) {
|
|
30
|
-
element && this._marks && this._marks.includes(element.mark) && element.addState(this.options.state)
|
|
30
|
+
element && this._marks && this._marks.includes(element.mark) && (element.addState(this.options.state),
|
|
31
|
+
this._prevActiveElement = element);
|
|
31
32
|
}
|
|
32
33
|
reset(element) {
|
|
33
|
-
|
|
34
|
+
const el = null != element ? element : this._prevActiveElement;
|
|
35
|
+
el && this._marks && this._marks.includes(el.mark) && el.removeState(this.options.state);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/element-active.ts"],"names":[],"mappings":";;;AAAA,0CAAsD;AAEtD,iCA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O,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACrC,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC;aACnC;SACF;IACH,CAAC;IAED,KAAK,CAAC,OAAqC;QACzC,MAAM,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,kBAAkB,CAAC;QAE9C,IAAI,EAAE,EAAE;YACN,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;gBAChD,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aACpC;SACF;IACH,CAAC;;AAnDH,sCA4DC;AA3DQ,kBAAI,GAAW,gBAAgB,CAAC;AAGhC,4BAAc,GAAyB;IAC5C,KAAK,EAAE,4BAAoB,CAAC,MAAM;IAClC,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,YAAY;CACzB,CAAC","file":"element-active.js","sourcesContent":["import { InteractionStateEnum } from '../graph/enums';\nimport type { ElementActiveOptions, IElement, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\n\nexport class ElementActive extends BaseInteraction<ElementActiveOptions> {\n static type: string = 'element-active';\n type: string = ElementActive.type;\n\n static defaultOptions: ElementActiveOptions = {\n state: InteractionStateEnum.active,\n trigger: 'pointerover',\n triggerOff: 'pointerout'\n };\n options: ElementActiveOptions;\n protected _marks?: IMark[];\n protected _prevActiveElement?: IElement;\n\n constructor(view: IView, options?: ElementActiveOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementActive.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.triggerOff, handler: this.handleReset }\n ];\n }\n\n getStartState(): string {\n return this.options.state;\n }\n\n start(element: InteractionEvent['element']) {\n if (element) {\n if (this._marks && this._marks.includes(element.mark)) {\n element.addState(this.options.state);\n this._prevActiveElement = element;\n }\n }\n }\n\n reset(element?: InteractionEvent['element']) {\n const el = element ?? this._prevActiveElement;\n\n if (el) {\n if (this._marks && this._marks.includes(el.mark)) {\n el.removeState(this.options.state);\n }\n }\n }\n\n handleStart = (e: InteractionEvent) => {\n this.start(e.element);\n };\n\n handleReset = (e: InteractionEvent) => {\n this.reset(e.element);\n };\n}\n"]}
|
|
@@ -12,9 +12,9 @@ export declare class ElementHighlightByGroup extends BaseInteraction<ElementHigh
|
|
|
12
12
|
type: "none" | import("../types").EventType;
|
|
13
13
|
handler: (e: InteractionEvent) => void;
|
|
14
14
|
}[];
|
|
15
|
-
|
|
15
|
+
resetAll(): void;
|
|
16
16
|
start(element: InteractionEvent['element']): void;
|
|
17
|
-
reset(element
|
|
17
|
+
reset(element?: InteractionEvent['element']): void;
|
|
18
18
|
handleStart: (e: InteractionEvent) => void;
|
|
19
19
|
handleReset: (e: InteractionEvent) => void;
|
|
20
20
|
}
|
|
@@ -11,7 +11,8 @@ class ElementHighlightByGroup extends base_1.BaseInteraction {
|
|
|
11
11
|
super(view, options), this.type = ElementHighlightByGroup.type, this.handleStart = e => {
|
|
12
12
|
this.start(e.element);
|
|
13
13
|
}, this.handleReset = e => {
|
|
14
|
-
|
|
14
|
+
const element = e.element;
|
|
15
|
+
element && this._marks && this._marks.includes(element.mark) && this.resetAll();
|
|
15
16
|
}, this.options = Object.assign({}, ElementHighlightByGroup.defaultOptions, options),
|
|
16
17
|
this._marks = view.getMarksBySelector(this.options.selector);
|
|
17
18
|
}
|
|
@@ -27,7 +28,7 @@ class ElementHighlightByGroup extends base_1.BaseInteraction {
|
|
|
27
28
|
handler: this.handleReset
|
|
28
29
|
} ];
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
resetAll() {
|
|
31
32
|
const states = [ this.options.highlightState, this.options.blurState ];
|
|
32
33
|
this._marks.forEach((mark => {
|
|
33
34
|
mark.elements.forEach((el => {
|
|
@@ -53,7 +54,7 @@ class ElementHighlightByGroup extends base_1.BaseInteraction {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
reset(element) {
|
|
56
|
-
element
|
|
57
|
+
element ? this._marks && this._marks.includes(element.mark) && element.removeState([ this.options.highlightState, this.options.blurState ]) : this.resetAll();
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|