@visactor/vutils-extension 1.11.0-alpha.2 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/cjs/index.d.ts +1 -0
  2. package/cjs/index.js +1 -1
  3. package/cjs/index.js.map +1 -1
  4. package/cjs/spec/clone-deep.d.ts +1 -0
  5. package/cjs/spec/clone-deep.js +27 -0
  6. package/cjs/spec/clone-deep.js.map +1 -0
  7. package/cjs/spec/common.d.ts +3 -0
  8. package/cjs/spec/common.js +23 -0
  9. package/cjs/spec/common.js.map +1 -0
  10. package/cjs/spec/index.d.ts +3 -0
  11. package/cjs/spec/index.js +22 -0
  12. package/cjs/spec/index.js.map +1 -0
  13. package/cjs/spec/merge-spec.d.ts +5 -0
  14. package/cjs/spec/merge-spec.js +69 -0
  15. package/cjs/spec/merge-spec.js.map +1 -0
  16. package/cjs/transform/tick-data/discrete/linear.js +1 -2
  17. package/cjs/transform/tick-data/interface.d.ts +1 -0
  18. package/cjs/transform/tick-data/interface.js.map +1 -1
  19. package/cjs/transform/tick-data/util.js +10 -9
  20. package/cjs/transform/tick-data/util.js.map +1 -1
  21. package/cjs/transform/tick-data/utils/polar-label-position.d.ts +8 -0
  22. package/cjs/transform/tick-data/utils/polar-label-position.js +20 -0
  23. package/cjs/transform/tick-data/utils/polar-label-position.js.map +1 -0
  24. package/es/index.d.ts +1 -0
  25. package/es/index.js +3 -1
  26. package/es/index.js.map +1 -1
  27. package/es/spec/clone-deep.d.ts +1 -0
  28. package/es/spec/clone-deep.js +20 -0
  29. package/es/spec/clone-deep.js.map +1 -0
  30. package/es/spec/common.d.ts +3 -0
  31. package/es/spec/common.js +15 -0
  32. package/es/spec/common.js.map +1 -0
  33. package/es/spec/index.d.ts +3 -0
  34. package/es/spec/index.js +6 -0
  35. package/es/spec/index.js.map +1 -0
  36. package/es/spec/merge-spec.d.ts +5 -0
  37. package/es/spec/merge-spec.js +57 -0
  38. package/es/spec/merge-spec.js.map +1 -0
  39. package/es/transform/tick-data/discrete/linear.js +1 -2
  40. package/es/transform/tick-data/interface.d.ts +1 -0
  41. package/es/transform/tick-data/interface.js.map +1 -1
  42. package/es/transform/tick-data/util.js +9 -8
  43. package/es/transform/tick-data/util.js.map +1 -1
  44. package/es/transform/tick-data/utils/polar-label-position.d.ts +8 -0
  45. package/es/transform/tick-data/utils/polar-label-position.js +12 -0
  46. package/es/transform/tick-data/utils/polar-label-position.js.map +1 -0
  47. package/package.json +12 -7
package/cjs/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './transform/tick-data';
2
2
  export * from './utils';
3
3
  export * from './algorithm';
4
+ export * from './spec';
package/cjs/index.js CHANGED
@@ -18,4 +18,4 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), __exportStar(require("./transform/tick-data"), exports), __exportStar(require("./utils"), exports),
21
- __exportStar(require("./algorithm"), exports);
21
+ __exportStar(require("./algorithm"), exports), __exportStar(require("./spec"), exports);
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,0CAAwB;AACxB,8CAA4B","file":"index.js","sourcesContent":["export * from './transform/tick-data';\nexport * from './utils';\nexport * from './algorithm';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,0CAAwB;AACxB,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["export * from './transform/tick-data';\nexport * from './utils';\nexport * from './algorithm';\nexport * from './spec';\n"]}
@@ -0,0 +1 @@
1
+ export declare function cloneDeepSpec(spec: any, excludeKeys?: string[]): any;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.cloneDeepSpec = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), common_1 = require("./common");
8
+
9
+ function cloneDeepSpec(spec, excludeKeys = [ "data" ]) {
10
+ const value = spec;
11
+ let result;
12
+ if (!(0, vutils_1.isValid)(value) || "object" != typeof value) return value;
13
+ if ((0, common_1.isDataView)(value) || (0, common_1.isHTMLElement)(value)) return value;
14
+ const isArr = (0, vutils_1.isArray)(value), length = value.length;
15
+ result = isArr ? new Array(length) : "object" == typeof value ? {} : (0, vutils_1.isBoolean)(value) || (0,
16
+ vutils_1.isNumber)(value) || (0, vutils_1.isString)(value) ? value : (0, vutils_1.isDate)(value) ? new Date(+value) : void 0;
17
+ const props = isArr ? void 0 : Object.keys(Object(value));
18
+ let index = -1;
19
+ if (result) for (;++index < (props || value).length; ) {
20
+ const key = props ? props[index] : index, subValue = value[key];
21
+ (null == excludeKeys ? void 0 : excludeKeys.includes(key.toString())) ? result[key] = subValue : result[key] = cloneDeepSpec(subValue, excludeKeys);
22
+ }
23
+ return result;
24
+ }
25
+
26
+ exports.cloneDeepSpec = cloneDeepSpec;
27
+ //# sourceMappingURL=clone-deep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/clone-deep.ts"],"names":[],"mappings":";;;AAAA,6CAA2F;AAC3F,qCAAqD;AAMrD,SAAgB,aAAa,CAAC,IAAS,EAAE,cAAwB,CAAC,MAAM,CAAC;IACvE,MAAM,KAAK,GAAG,IAAI,CAAC;IAEnB,IAAI,MAAM,CAAC;IACX,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAChD,OAAO,KAAK,CAAC;KACd;IAGD,IAAI,IAAA,mBAAU,EAAC,KAAK,CAAC,IAAI,IAAA,sBAAa,EAAC,KAAK,CAAC,EAAE;QAC7C,OAAO,KAAK,CAAC;KACd;IAED,MAAM,KAAK,GAAG,IAAA,gBAAO,EAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,M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C;AAChB,CAAC;AArDD,sCAqDC","file":"clone-deep.js","sourcesContent":["import { isArray, isBoolean, isDate, isNumber, isString, isValid } from '@visactor/vutils';\nimport { isDataView, isHTMLElement } from './common';\n\n/**\n * 深拷贝 spec,为避免循环引用,DataView 维持原有引用\n * @param spec 原spec\n */\nexport function cloneDeepSpec(spec: any, excludeKeys: string[] = ['data']) {\n const value = spec;\n\n let result;\n if (!isValid(value) || typeof value !== 'object') {\n return value;\n }\n\n // 判断是不是不能深拷贝的对象\n if (isDataView(value) || isHTMLElement(value)) {\n return value;\n }\n\n const isArr = isArray(value);\n const length = value.length;\n // 不考虑特殊数组的额外处理\n if (isArr) {\n result = new Array(length);\n }\n // 不考虑 buffer / arguments 类型的处理以及 prototype 的额外处理\n else if (typeof value === 'object') {\n result = {};\n }\n // 不建议使用作为 Boolean / Number / String 作为构造器\n else if (isBoolean(value) || isNumber(value) || isString(value)) {\n result = value;\n } else if (isDate(value)) {\n result = new Date(+value);\n }\n // 不考虑 ArrayBuffer / DataView / TypedArray / map / set / regexp / symbol 类型\n else {\n result = undefined;\n }\n\n // 不考虑 map / set / TypedArray 类型的赋值\n\n // 不考虑对象的 symbol 属性\n const props = isArr ? undefined : Object.keys(Object(value));\n\n let index = -1;\n if (result) {\n while (++index < (props || value).length) {\n const key = props ? props[index] : index;\n const subValue = value[key];\n if (excludeKeys?.includes(key.toString())) {\n result[key] = subValue;\n } else {\n result[key] = cloneDeepSpec(subValue, excludeKeys);\n }\n }\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { DataView } from '@visactor/vdataset';
2
+ export declare function isDataView(obj: any): obj is DataView;
3
+ export declare function isHTMLElement(obj: any): obj is Element;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.isHTMLElement = exports.isDataView = void 0;
6
+
7
+ const vdataset_1 = require("@visactor/vdataset");
8
+
9
+ function isDataView(obj) {
10
+ return obj instanceof vdataset_1.DataView;
11
+ }
12
+
13
+ function isHTMLElement(obj) {
14
+ try {
15
+ return obj instanceof Element;
16
+ } catch (_a) {
17
+ const htmlElementKeys = [ "children", "innerHTML", "classList", "setAttribute", "tagName", "getBoundingClientRect" ], keys = Object.keys(obj);
18
+ return htmlElementKeys.every((key => keys.includes(key)));
19
+ }
20
+ }
21
+
22
+ exports.isDataView = isDataView, exports.isHTMLElement = isHTMLElement;
23
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/common.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAE9C,SAAgB,UAAU,CAAC,GAAQ;IACjC,OAAO,GAAG,YAAY,mBAAQ,CAAC;AACjC,CAAC;AAFD,gCAEC;AAED,SAAgB,aAAa,CAAC,GAAQ;IACpC,IAAI;QACF,OAAO,GAAG,YAAY,OAAO,CAAC;KAC/B;IAAC,WAAM;QAEN,MAAM,eAAe,GAAsB;YACzC,UAAU;YACV,WAAW;YACX,WAAW;YACX,cAAc;YACd,SAAS;YACT,uBAAuB;SACxB,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;KACzD;AACH,CAAC;AAhBD,sCAgBC","file":"common.js","sourcesContent":["import { DataView } from '@visactor/vdataset';\n\nexport function isDataView(obj: any): obj is DataView {\n return obj instanceof DataView;\n}\n\nexport function isHTMLElement(obj: any): obj is Element {\n try {\n return obj instanceof Element;\n } catch {\n // 跨端 plan B\n const htmlElementKeys: (keyof Element)[] = [\n 'children',\n 'innerHTML',\n 'classList',\n 'setAttribute',\n 'tagName',\n 'getBoundingClientRect'\n ];\n const keys = Object.keys(obj);\n return htmlElementKeys.every(key => keys.includes(key));\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './clone-deep';
2
+ export * from './common';
3
+ export * from './merge-spec';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
+ void 0 === k2 && (k2 = k);
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return m[k];
10
+ }
11
+ }), Object.defineProperty(o, k2, desc);
12
+ } : function(o, m, k, k2) {
13
+ void 0 === k2 && (k2 = k), o[k2] = m[k];
14
+ }), __exportStar = this && this.__exportStar || function(m, exports) {
15
+ for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
16
+ };
17
+
18
+ Object.defineProperty(exports, "__esModule", {
19
+ value: !0
20
+ }), __exportStar(require("./clone-deep"), exports), __exportStar(require("./common"), exports),
21
+ __exportStar(require("./merge-spec"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,2CAAyB;AACzB,+CAA6B","file":"index.js","sourcesContent":["export * from './clone-deep';\nexport * from './common';\nexport * from './merge-spec';\n"]}
@@ -0,0 +1,5 @@
1
+ export declare function mergeSpec(target: any, ...sources: any[]): any;
2
+ export declare function mergeSpecWithFilter(target: any, filter: string | {
3
+ type: string;
4
+ index: number;
5
+ }, spec: any, forceMerge: boolean): void;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.mergeSpecWithFilter = exports.mergeSpec = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils");
8
+
9
+ function baseMerge(target, source, shallowArray = !1) {
10
+ if (source) {
11
+ if (target === source) return;
12
+ if ((0, vutils_1.isValid)(source) && "object" == typeof source) {
13
+ const iterable = Object(source), props = [];
14
+ for (const key in iterable) props.push(key);
15
+ let {length: length} = props, propIndex = -1;
16
+ for (;length--; ) {
17
+ const key = props[++propIndex];
18
+ (0, vutils_1.isValid)(iterable[key]) && "object" == typeof iterable[key] && !(0,
19
+ vutils_1.isArray)(target[key]) ? baseMergeDeep(target, source, key, shallowArray) : assignMergeValue(target, key, iterable[key]);
20
+ }
21
+ }
22
+ }
23
+ }
24
+
25
+ function baseMergeDeep(target, source, key, shallowArray = !1) {
26
+ const objValue = target[key], srcValue = source[key];
27
+ let newValue = source[key], isCommon = !0;
28
+ if ((0, vutils_1.isArray)(srcValue)) {
29
+ if (shallowArray) newValue = []; else if ((0, vutils_1.isArray)(objValue)) newValue = objValue; else if ((0,
30
+ vutils_1.isArrayLike)(objValue)) {
31
+ newValue = new Array(objValue.length);
32
+ let index = -1;
33
+ const length = objValue.length;
34
+ for (;++index < length; ) newValue[index] = objValue[index];
35
+ }
36
+ } else (0, vutils_1.isPlainObject)(srcValue) ? (newValue = null != objValue ? objValue : {},
37
+ "function" != typeof objValue && "object" == typeof objValue || (newValue = {})) : isCommon = !1;
38
+ isCommon && baseMerge(newValue, srcValue, shallowArray), assignMergeValue(target, key, newValue);
39
+ }
40
+
41
+ function assignMergeValue(target, key, value) {
42
+ (void 0 !== value && !eq(target[key], value) || void 0 === value && !(key in target)) && (target[key] = value);
43
+ }
44
+
45
+ function eq(value, other) {
46
+ return value === other || Number.isNaN(value) && Number.isNaN(other);
47
+ }
48
+
49
+ function mergeSpec(target, ...sources) {
50
+ let sourceIndex = -1;
51
+ const length = sources.length;
52
+ for (;++sourceIndex < length; ) {
53
+ baseMerge(target, sources[sourceIndex], !0);
54
+ }
55
+ return target;
56
+ }
57
+
58
+ function mergeSpecWithFilter(target, filter, spec, forceMerge) {
59
+ Object.keys(target).forEach((k => {
60
+ if ((0, vutils_1.isObject)(filter)) filter.type === k && ((0, vutils_1.isArray)(target[k]) ? target[k].length >= filter.index && (target[k][filter.index] = forceMerge ? mergeSpec({}, target[k][filter.index], spec) : spec) : target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec); else if ((0,
61
+ vutils_1.isArray)(target[k])) {
62
+ const index = target[k].findIndex((_s => _s.id === filter));
63
+ index >= 0 && (target[k][index] = forceMerge ? mergeSpec({}, target[k][index], spec) : spec);
64
+ } else target.id === filter && (target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec);
65
+ }));
66
+ }
67
+
68
+ exports.mergeSpec = mergeSpec, exports.mergeSpecWithFilter = mergeSpecWithFilter;
69
+ //# sourceMappingURL=merge-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/merge-spec.ts"],"names":[],"mappings":";;;AAAA,6CAA0F;AAE1F,SAAS,SAAS,CAAC,MAAW,EAAE,MAAW,EAAE,YAAY,GAAG,KAAK;IAC/D,IAAI,MAAM,EAAE;QACV,IAAI,MAAM,KAAK,MAAM,EAAE;YACrB,OAAO;SACR;QACD,IAAI,IAAA,gBAAO,EAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAEjD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAChC,MAAM,KAAK,GAAG,EAAE,CAAC;YAEjB,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;gBAC1B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACjB;YACD,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;YACvB,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,MAAM,EAAE,EAAE;gBACf,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;gBAC/B,IACE,IAAA,gBAAO,EAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;oBACtB,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,QAAQ;oBACjC,CAAC,IAAA,gBAAO,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EACrB;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C,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;aAChE;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AA7BD,kDA6BC","file":"merge-spec.js","sourcesContent":["import { isArray, isArrayLike, isObject, isPlainObject, isValid } from '@visactor/vutils';\n\nfunction baseMerge(target: any, source: any, shallowArray = false) {\n if (source) {\n if (target === source) {\n return;\n }\n if (isValid(source) && typeof source === 'object') {\n // baseFor\n const iterable = Object(source);\n const props = [];\n // keysIn\n for (const key in iterable) {\n props.push(key);\n }\n let { length } = props;\n let propIndex = -1;\n while (length--) {\n const key = props[++propIndex];\n if (\n isValid(iterable[key]) &&\n typeof iterable[key] === 'object' &&\n !isArray(target[key]) // VChart 特有逻辑\n ) {\n baseMergeDeep(target, source, key, shallowArray);\n } else {\n assignMergeValue(target, key, iterable[key]);\n }\n }\n }\n }\n}\n\n// 由于目前 VChart 内部对 spec 会先执行一次深拷贝,merge 暂时不考虑 source 中有环的问题\nfunction baseMergeDeep(target: object, source: object, key: string, shallowArray = false) {\n const objValue = target[key];\n const srcValue = source[key];\n let newValue = source[key];\n let isCommon = true;\n // 不考虑 buffer / typedArray 类型\n if (isArray(srcValue)) {\n if (shallowArray) {\n // 依据参数对数组做浅拷贝\n newValue = [];\n } else if (isArray(objValue)) {\n newValue = objValue;\n } else if (isArrayLike(objValue)) {\n // 如果 source 为数组,则 target 的 arrayLike 对象也视作为数组处理\n newValue = new Array(objValue.length);\n let index = -1;\n const length = objValue.length;\n while (++index < length) {\n newValue[index] = objValue[index];\n }\n }\n }\n // else if (isArray(srcValue) && shallowArray) {\n // newValue = [];\n // }\n // 不考虑 argument 类型\n else if (isPlainObject(srcValue)) {\n newValue = objValue ?? {};\n // 不考虑 prototype 的额外处理\n if (typeof objValue === 'function' || typeof objValue !== 'object') {\n newValue = {};\n }\n } else {\n isCommon = false;\n }\n // 对 class 等复杂对象或者浅拷贝的 array 不做拷贝处理\n if (isCommon) {\n baseMerge(newValue, srcValue, shallowArray);\n }\n assignMergeValue(target, key, newValue);\n}\n\nfunction assignMergeValue(target: object, key: string, value: any) {\n if ((value !== undefined && !eq(target[key], value)) || (value === undefined && !(key in target))) {\n // 不考虑 __proto__ 的赋值处理\n target[key] = value;\n }\n}\n\nfunction eq(value: any, other: any) {\n return value === other || (Number.isNaN(value) && Number.isNaN(other));\n}\n\n/* 与原生的 lodash merge 差异在于对数组是否应用最后一个 source 的结果\n * 以及对一些特殊情况的处理,比如对数组类型 padding 和对象类型的 padding 的 merge\n */\nexport function mergeSpec(target: any, ...sources: any[]): any {\n let sourceIndex = -1;\n const length = sources.length;\n while (++sourceIndex < length) {\n const source = sources[sourceIndex];\n baseMerge(target, source, true);\n }\n return target;\n}\n\nexport function mergeSpecWithFilter(\n target: any,\n filter: string | { type: string; index: number },\n spec: any,\n forceMerge: boolean\n) {\n Object.keys(target).forEach(k => {\n if (isObject(filter)) {\n if (filter.type === k) {\n if (isArray(target[k])) {\n if (target[k].length >= filter.index) {\n target[k][filter.index] = forceMerge ? mergeSpec({}, target[k][filter.index], spec) : spec;\n }\n } else {\n target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec;\n }\n }\n } else {\n // filter === user id\n if (isArray(target[k])) {\n const index = target[k].findIndex((_s: { id: string | number }) => _s.id === filter);\n if (index >= 0) {\n target[k][index] = forceMerge ? mergeSpec({}, target[k][index], spec) : spec;\n }\n } else if (target.id === filter) {\n target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec;\n }\n }\n });\n}\n"]}
@@ -97,5 +97,4 @@ const getStep = (domain, labelBoundsList, labelGap, labelLastVisible, defaultSte
97
97
  step: resultStep,
98
98
  delCount: resultDelCount
99
99
  };
100
- };
101
- //# sourceMappingURL=linear.js.map
100
+ };
@@ -25,6 +25,7 @@ export interface IPolarTickDataOpt extends ITickDataOpt {
25
25
  axisOrientType: IPolarOrientType;
26
26
  getRadius: () => number;
27
27
  labelOffset: number;
28
+ inside: boolean;
28
29
  }
29
30
  export interface ITickData {
30
31
  index: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/transform/tick-data/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import { ITextGraphicAttribute } from '@visactor/vrender-core';\n\nexport type CoordinateType = 'cartesian' | 'polar' | 'geo' | 'none';\nexport type IOrientType = 'left' | 'top' | 'right' | 'bottom' | 'z';\nexport type IPolarOrientType = 'radius' | 'angle';\n\nexport interface ITickDataOpt {\n /**\n * 是否进行轴采样\n */\n sampling?: boolean;\n tickCount?: number | ((option: ITickCallbackOption) => number);\n forceTickCount?: number;\n tickStep?: number;\n tickMode?: 'average' | 'd3' | string;\n noDecimals?: boolean;\n\n coordinateType: CoordinateType;\n axisOrientType: IOrientType | IPolarOrientType;\n startAngle?: number;\n\n labelFormatter?: (value: any) => string;\n labelStyle: ITextGraphicAttribute;\n labelGap?: number;\n}\n\nexport interface ICartesianTickDataOpt extends ITickDataOpt {\n axisOrientType: IOrientType;\n labelLastVisible: boolean;\n labelFlush: boolean;\n}\n\nexport interface IPolarTickDataOpt extends ITickDataOpt {\n axisOrientType: IPolarOrientType;\n getRadius: () => number;\n labelOffset: number;\n}\n\nexport interface ITickData {\n index: number;\n value: number | string;\n // label: string;\n}\n\ntype ITickCallbackOption = {\n /**\n * 坐标轴占据的画布大小。\n * 直角坐标系中为轴的宽度或高度。\n * 极坐标系中半径轴的长度。\n */\n axisLength?: number;\n /**\n * 轴标签的样式\n */\n labelStyle?: ITextGraphicAttribute;\n};\n"]}
1
+ {"version":3,"sources":["../src/transform/tick-data/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import { ITextGraphicAttribute } from '@visactor/vrender-core';\n\nexport type CoordinateType = 'cartesian' | 'polar' | 'geo' | 'none';\nexport type IOrientType = 'left' | 'top' | 'right' | 'bottom' | 'z';\nexport type IPolarOrientType = 'radius' | 'angle';\n\nexport interface ITickDataOpt {\n /**\n * 是否进行轴采样\n */\n sampling?: boolean;\n tickCount?: number | ((option: ITickCallbackOption) => number);\n forceTickCount?: number;\n tickStep?: number;\n tickMode?: 'average' | 'd3' | string;\n noDecimals?: boolean;\n\n coordinateType: CoordinateType;\n axisOrientType: IOrientType | IPolarOrientType;\n startAngle?: number;\n\n labelFormatter?: (value: any) => string;\n labelStyle: ITextGraphicAttribute;\n labelGap?: number;\n}\n\nexport interface ICartesianTickDataOpt extends ITickDataOpt {\n axisOrientType: IOrientType;\n labelLastVisible: boolean;\n labelFlush: boolean;\n}\n\nexport interface IPolarTickDataOpt extends ITickDataOpt {\n axisOrientType: IPolarOrientType;\n getRadius: () => number;\n labelOffset: number;\n inside: boolean;\n}\n\nexport interface ITickData {\n index: number;\n value: number | string;\n // label: string;\n}\n\ntype ITickCallbackOption = {\n /**\n * 坐标轴占据的画布大小。\n * 直角坐标系中为轴的宽度或高度。\n * 极坐标系中半径轴的长度。\n */\n axisLength?: number;\n /**\n * 轴标签的样式\n */\n labelStyle?: ITextGraphicAttribute;\n};\n"]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.isAxisHorizontal = exports.getPolarAngleLabelBounds = exports.getCartesianLabelBounds = exports.MIN_TICK_GAP = exports.hasOverlap = exports.intersect = exports.labelDistance = exports.labelOverlap = exports.convertDomainToTickData = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), text_1 = require("../../utils/text"), polar_1 = require("../../utils/polar"), convertDomainToTickData = domain => domain.map(((t, index) => ({
7
+ const vutils_1 = require("@visactor/vutils"), text_1 = require("../../utils/text"), polar_label_position_1 = require("./utils/polar-label-position"), convertDomainToTickData = domain => domain.map(((t, index) => ({
8
8
  index: index,
9
9
  value: t
10
10
  })));
@@ -66,20 +66,21 @@ exports.getCartesianLabelBounds = getCartesianLabelBounds;
66
66
 
67
67
  const getPolarAngleLabelBounds = (scale, domain, op) => {
68
68
  var _a;
69
- const {labelStyle: labelStyle, getRadius: getRadius, labelOffset: labelOffset, labelFormatter: labelFormatter} = op, radius = null == getRadius ? void 0 : getRadius(), labelAngle = null !== (_a = labelStyle.angle) && void 0 !== _a ? _a : 0, textMeasure = (0,
70
- text_1.initTextMeasure)(labelStyle);
71
- return domain.map((v => {
69
+ const {labelStyle: labelStyle, getRadius: getRadius, labelOffset: labelOffset, labelFormatter: labelFormatter, inside: inside} = op, radius = null == getRadius ? void 0 : getRadius(), labelAngle = null !== (_a = labelStyle.angle) && void 0 !== _a ? _a : 0, textMeasure = (0,
70
+ text_1.initTextMeasure)(labelStyle), labelBoundsList = domain.map((v => {
71
+ var _a, _b;
72
72
  const str = labelFormatter ? labelFormatter(v) : `${v}`, {width: width, height: height} = textMeasure.quickMeasure(str), textWidth = Math.max(width, exports.MIN_TICK_GAP), textHeight = Math.max(height, exports.MIN_TICK_GAP), angle = scale.scale(v);
73
73
  let textX = 0, textY = 0;
74
- const orient = (0, polar_1.angleLabelOrientAttribute)(angle), {x: x, y: y} = (0,
75
- vutils_1.polarToCartesian)({
74
+ const orient_align = null !== (_a = labelStyle.textAlign) && void 0 !== _a ? _a : "center", orient_baseline = null !== (_b = labelStyle.textBaseline) && void 0 !== _b ? _b : "middle", {x: x, y: y} = (0,
75
+ polar_label_position_1.getLabelPosition)(angle, {
76
76
  x: 0,
77
77
  y: 0
78
- }, radius + labelOffset, angle);
79
- textX = x + ("right" === orient.align ? -textWidth : "center" === orient.align ? -textWidth / 2 : 0),
80
- textY = y + ("bottom" === orient.baseline ? -textHeight : "middle" === orient.baseline ? -textHeight / 2 : 0);
78
+ }, radius, labelOffset, inside, str, labelStyle);
79
+ textX = x + ("right" === orient_align ? -textWidth : "center" === orient_align ? -textWidth / 2 : 0),
80
+ textY = y + ("bottom" === orient_baseline ? -textHeight : "middle" === orient_baseline ? -textHeight / 2 : 0);
81
81
  return (new vutils_1.AABBBounds).set(textX, textY, textX + textWidth, textY + textHeight).rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);
82
82
  }));
83
+ return labelBoundsList;
83
84
  };
84
85
 
85
86
  exports.getPolarAngleLabelBounds = getPolarAngleLabelBounds;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/transform/tick-data/util.ts"],"names":[],"mappings":";;;AAGA,6CAAgF;AAEhF,2CAAmD;AACnD,6CAA8D;AAGvD,MAAM,uBAAuB,GAAG,CAAC,MAAa,EAAe,EAAE;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,KAAa,EAAE,EAAE;QACpD,OAAO;YACL,KAAK;YACL,KAAK,EAAE,CAAC;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AARW,QAAA,uBAAuB,2BAQlC;AAGK,MAAM,YAAY,GAAG,CAAC,SAAqB,EAAE,SAAqB,EAAE,GAAG,GAAG,CAAC,EAAW,EAAE;IAC7F,MAAM,UAAU,GAAG,IAAI,mBAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,IAAI,mBAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,OAAO,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAGK,MAAM,aAAa,GAAG,CAAC,SAAqB,EAAE,SAAqB,EAAoB,EAAE;IAC9F,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE;QAC/B,UAAU,GAAG,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;KAC1C;SAAM,IAAI,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE;QACtC,UAAU,GAAG,SAAS,CAAC,EAAE,GAAG,SAAS,CA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CAAC,CAAC;AA/BW,QAAA,wBAAwB,4BA+BnC;AAEK,MAAM,gBAAgB,GAAG,CAAC,cAA2B,EAAE,EAAE;IAC9D,OAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAmB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAC5E,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B","file":"util.js","sourcesContent":["import type { IBaseScale } from '@visactor/vscale';\nimport type { IBoundsLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { AABBBounds, degreeToRadian, polarToCartesian } from '@visactor/vutils';\nimport type { IGraphic, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\nimport { initTextMeasure } from '../../utils/text';\nimport { angleLabelOrientAttribute } from '../../utils/polar';\nimport type { ICartesianTickDataOpt, IOrientType, IPolarTickDataOpt, ITickData } from './interface';\n\nexport const convertDomainToTickData = (domain: any[]): ITickData[] => {\n const ticks = domain.map((t: number, index: number) => {\n return {\n index,\n value: t\n };\n });\n return ticks;\n};\n\n/** 判断两个label是否有重叠情况 */\nexport const labelOverlap = (prevLabel: AABBBounds, nextLabel: AABBBounds, gap = 0): boolean => {\n const prevBounds = new AABBBounds(prevLabel).expand(gap / 2);\n const nextBounds = new AABBBounds(nextLabel).expand(gap / 2);\n return prevBounds.intersects(nextBounds);\n};\n\n/** 判断两个不相交的label相隔的距离 */\nexport const labelDistance = (prevLabel: AABBBounds, nextLabel: AABBBounds): [number, number] => {\n let horizontal = 0;\n if (prevLabel.x2 < nextLabel.x1) {\n horizontal = nextLabel.x1 - prevLabel.x2;\n } else if (nextLabel.x2 < prevLabel.x1) {\n horizontal = prevLabel.x1 - nextLabel.x2;\n }\n\n let vertical = 0;\n if (prevLabel.y2 < nextLabel.y1) {\n vertical = nextLabel.y1 - prevLabel.y2;\n } else if (nextLabel.y2 < prevLabel.y1) {\n vertical = prevLabel.y1 - nextLabel.y2;\n }\n\n return [horizontal, vertical];\n};\n\nexport function intersect(a: IBoundsLike, b: IBoundsLike, sep: number) {\n return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);\n}\n\nexport interface ILabelItem<T> extends Pick<IGraphic, 'AABBBounds'> {\n value?: T;\n}\n\nexport function hasOverlap<T>(items: ILabelItem<T>[], pad: number): boolean {\n for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {\n b = items[i];\n if (intersect(a.AABBBounds, b.AABBBounds, pad)) {\n return true;\n }\n }\n return false;\n}\n\nexport const MIN_TICK_GAP = 12;\n\nexport const getCartesianLabelBounds = (scale: IBaseScale, domain: any[], op: ICartesianTickDataOpt): AABBBounds[] => {\n const { labelStyle, axisOrientType, labelFlush, labelFormatter, startAngle = 0 } = op;\n let labelAngle = labelStyle.angle ?? 0;\n if (labelStyle.direction === 'vertical') {\n labelAngle += degreeToRadian(90);\n }\n const isHorizontal = ['bottom', 'top'].includes(axisOrientType);\n const isVertical = ['left', 'right'].includes(axisOrientType);\n let scaleX = 1;\n let scaleY = 0;\n if (isHorizontal) {\n // nothing to update\n } else if (isVertical) {\n scaleX = 0;\n scaleY = 1;\n } else if (startAngle) {\n scaleX = Math.cos(startAngle);\n scaleY = -Math.sin(startAngle);\n }\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any, i: number) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const pos = scale.scale(v);\n const baseTextX = scaleX * pos;\n const baseTextY = scaleY * pos;\n let textX = baseTextX;\n let textY = baseTextY;\n\n let align: TextAlignType;\n if (labelFlush && isHorizontal && i === 0) {\n align = 'left';\n } else if (labelFlush && isHorizontal && i === domain.length - 1) {\n align = 'right';\n } else {\n align = labelStyle.textAlign ?? 'center';\n }\n if (align === 'right') {\n textX -= textWidth;\n } else if (align === 'center') {\n textX -= textWidth / 2;\n }\n\n let baseline: TextBaselineType;\n if (labelFlush && isVertical && i === 0) {\n baseline = 'top';\n } else if (labelFlush && isVertical && i === domain.length - 1) {\n baseline = 'bottom';\n } else {\n baseline = labelStyle.textBaseline ?? 'middle';\n }\n if (baseline === 'bottom') {\n textY -= textHeight;\n } else if (baseline === 'middle') {\n textY -= textHeight / 2;\n }\n\n // 计算 label 包围盒\n const bounds = new AABBBounds().set(textX, textY, textX + textWidth, textY + textHeight);\n\n if (labelAngle) {\n bounds.rotate(labelAngle, baseTextX, baseTextY);\n }\n\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const getPolarAngleLabelBounds = (scale: IBaseScale, domain: any[], op: IPolarTickDataOpt): AABBBounds[] => {\n const { labelStyle, getRadius, labelOffset, labelFormatter } = op;\n const radius = getRadius?.();\n const labelAngle = labelStyle.angle ?? 0;\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const angle = scale.scale(v);\n let textX = 0;\n let textY = 0;\n const orient = angleLabelOrientAttribute(angle);\n const { x, y } = polarToCartesian({ x: 0, y: 0 }, radius + labelOffset, angle);\n textX = x + (orient.align === 'right' ? -textWidth : orient.align === 'center' ? -textWidth / 2 : 0);\n textY = y + (orient.baseline === 'bottom' ? -textHeight : orient.baseline === 'middle' ? -textHeight / 2 : 0);\n\n // 计算 label 包围盒\n const bounds = new AABBBounds()\n .set(textX, textY, textX + textWidth, textY + textHeight)\n .rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const isAxisHorizontal = (axisOrientType: IOrientType) => {\n return (['bottom', 'top', 'z'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,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAnCW,QAAA,wBAAwB,4BAmCnC;AAEK,MAAM,gBAAgB,GAAG,CAAC,cAA2B,EAAE,EAAE;IAC9D,OAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAmB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAC5E,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B","file":"util.js","sourcesContent":["import type { IBaseScale } from '@visactor/vscale';\nimport type { IBoundsLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { AABBBounds, degreeToRadian } from '@visactor/vutils';\nimport type { IGraphic, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\nimport { initTextMeasure } from '../../utils/text';\nimport type { ICartesianTickDataOpt, IOrientType, IPolarTickDataOpt, ITickData } from './interface';\nimport { getLabelPosition } from './utils/polar-label-position';\n\nexport const convertDomainToTickData = (domain: any[]): ITickData[] => {\n const ticks = domain.map((t: number, index: number) => {\n return {\n index,\n value: t\n };\n });\n return ticks;\n};\n\n/** 判断两个label是否有重叠情况 */\nexport const labelOverlap = (prevLabel: AABBBounds, nextLabel: AABBBounds, gap = 0): boolean => {\n const prevBounds = new AABBBounds(prevLabel).expand(gap / 2);\n const nextBounds = new AABBBounds(nextLabel).expand(gap / 2);\n return prevBounds.intersects(nextBounds);\n};\n\n/** 判断两个不相交的label相隔的距离 */\nexport const labelDistance = (prevLabel: AABBBounds, nextLabel: AABBBounds): [number, number] => {\n let horizontal = 0;\n if (prevLabel.x2 < nextLabel.x1) {\n horizontal = nextLabel.x1 - prevLabel.x2;\n } else if (nextLabel.x2 < prevLabel.x1) {\n horizontal = prevLabel.x1 - nextLabel.x2;\n }\n\n let vertical = 0;\n if (prevLabel.y2 < nextLabel.y1) {\n vertical = nextLabel.y1 - prevLabel.y2;\n } else if (nextLabel.y2 < prevLabel.y1) {\n vertical = prevLabel.y1 - nextLabel.y2;\n }\n\n return [horizontal, vertical];\n};\n\nexport function intersect(a: IBoundsLike, b: IBoundsLike, sep: number) {\n return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);\n}\n\nexport interface ILabelItem<T> extends Pick<IGraphic, 'AABBBounds'> {\n value?: T;\n}\n\nexport function hasOverlap<T>(items: ILabelItem<T>[], pad: number): boolean {\n for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {\n b = items[i];\n if (intersect(a.AABBBounds, b.AABBBounds, pad)) {\n return true;\n }\n }\n return false;\n}\n\nexport const MIN_TICK_GAP = 12;\n\nexport const getCartesianLabelBounds = (scale: IBaseScale, domain: any[], op: ICartesianTickDataOpt): AABBBounds[] => {\n const { labelStyle, axisOrientType, labelFlush, labelFormatter, startAngle = 0 } = op;\n let labelAngle = labelStyle.angle ?? 0;\n if (labelStyle.direction === 'vertical') {\n labelAngle += degreeToRadian(90);\n }\n const isHorizontal = ['bottom', 'top'].includes(axisOrientType);\n const isVertical = ['left', 'right'].includes(axisOrientType);\n let scaleX = 1;\n let scaleY = 0;\n if (isHorizontal) {\n // nothing to update\n } else if (isVertical) {\n scaleX = 0;\n scaleY = 1;\n } else if (startAngle) {\n scaleX = Math.cos(startAngle);\n scaleY = -Math.sin(startAngle);\n }\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any, i: number) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const pos = scale.scale(v);\n const baseTextX = scaleX * pos;\n const baseTextY = scaleY * pos;\n let textX = baseTextX;\n let textY = baseTextY;\n\n let align: TextAlignType;\n if (labelFlush && isHorizontal && i === 0) {\n align = 'left';\n } else if (labelFlush && isHorizontal && i === domain.length - 1) {\n align = 'right';\n } else {\n align = labelStyle.textAlign ?? 'center';\n }\n if (align === 'right') {\n textX -= textWidth;\n } else if (align === 'center') {\n textX -= textWidth / 2;\n }\n\n let baseline: TextBaselineType;\n if (labelFlush && isVertical && i === 0) {\n baseline = 'top';\n } else if (labelFlush && isVertical && i === domain.length - 1) {\n baseline = 'bottom';\n } else {\n baseline = labelStyle.textBaseline ?? 'middle';\n }\n if (baseline === 'bottom') {\n textY -= textHeight;\n } else if (baseline === 'middle') {\n textY -= textHeight / 2;\n }\n\n // 计算 label 包围盒\n const bounds = new AABBBounds().set(textX, textY, textX + textWidth, textY + textHeight);\n\n if (labelAngle) {\n bounds.rotate(labelAngle, baseTextX, baseTextY);\n }\n\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const getPolarAngleLabelBounds = (scale: IBaseScale, domain: any[], op: IPolarTickDataOpt): AABBBounds[] => {\n const { labelStyle, getRadius, labelOffset, labelFormatter, inside } = op;\n const radius = getRadius?.();\n const labelAngle = labelStyle.angle ?? 0;\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const angle = scale.scale(v);\n let textX = 0;\n let textY = 0;\n const orient = {\n align: labelStyle.textAlign ?? 'center',\n baseline: labelStyle.textBaseline ?? 'middle'\n };\n\n const { x, y } = getLabelPosition(angle, { x: 0, y: 0 }, radius, labelOffset, inside, str, labelStyle);\n textX = x + (orient.align === 'right' ? -textWidth : orient.align === 'center' ? -textWidth / 2 : 0);\n textY = y + (orient.baseline === 'bottom' ? -textHeight : orient.baseline === 'middle' ? -textHeight / 2 : 0);\n\n // 计算 label 包围盒\n const bounds = new AABBBounds()\n .set(textX, textY, textX + textWidth, textY + textHeight)\n .rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const isAxisHorizontal = (axisOrientType: IOrientType) => {\n return (['bottom', 'top', 'z'] as IOrientType[]).includes(axisOrientType);\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import { ITextGraphicAttribute } from '@visactor/vrender-core';
2
+ export declare function getLabelPosition(angle: number, center: {
3
+ x: number;
4
+ y: number;
5
+ }, radius: number, labelOffset: number, inside: boolean, text: string | number, style: Partial<ITextGraphicAttribute>): {
6
+ x: number;
7
+ y: number;
8
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.getLabelPosition = void 0;
6
+
7
+ const vrender_components_1 = require("@visactor/vrender-components"), vutils_1 = require("@visactor/vutils");
8
+
9
+ function getLabelPosition(angle, center, radius, labelOffset, inside, text, style) {
10
+ const point = (0, vutils_1.polarToCartesian)({
11
+ x: 0,
12
+ y: 0
13
+ }, radius, angle), labelPoint = (0, vrender_components_1.getVerticalCoord)(point, (0,
14
+ vrender_components_1.getCircleVerticalVector)(labelOffset, point, center, inside)), vector = (0,
15
+ vrender_components_1.getCircleVerticalVector)(labelOffset || 1, labelPoint, center, inside);
16
+ return (0, vrender_components_1.getCircleLabelPosition)(labelPoint, vector, text, style);
17
+ }
18
+
19
+ exports.getLabelPosition = getLabelPosition;
20
+ //# sourceMappingURL=polar-label-position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/transform/tick-data/utils/polar-label-position.ts"],"names":[],"mappings":";;;AACA,qEAAiH;AACjH,6CAAoD;AAEpD,SAAgB,gBAAgB,CAC9B,KAAa,EACb,MAAgC,EAChC,MAAc,EACd,WAAmB,EACnB,MAAe,EACf,IAAqB,EACrB,KAAqC;IAErC,MAAM,KAAK,GAAG,IAAA,yBAAgB,EAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,IAAA,qCAAgB,EAAC,KAAK,EAAE,IAAA,4CAAuB,EAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxG,MAAM,MAAM,GAAG,IAAA,4CAAuB,EAAC,WAAW,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrF,OAAO,IAAA,2CAAsB,EAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC;AAbD,4CAaC","file":"polar-label-position.js","sourcesContent":["import { ITextGraphicAttribute } from '@visactor/vrender-core';\nimport { getCircleLabelPosition, getCircleVerticalVector, getVerticalCoord } from '@visactor/vrender-components';\nimport { polarToCartesian } from '@visactor/vutils';\n\nexport function getLabelPosition(\n angle: number,\n center: { x: number; y: number },\n radius: number,\n labelOffset: number,\n inside: boolean,\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n) {\n const point = polarToCartesian({ x: 0, y: 0 }, radius, angle);\n const labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside));\n const vector = getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside);\n return getCircleLabelPosition(labelPoint, vector, text, style);\n}\n"]}
package/es/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './transform/tick-data';
2
2
  export * from './utils';
3
3
  export * from './algorithm';
4
+ export * from './spec';
package/es/index.js CHANGED
@@ -2,4 +2,6 @@ export * from "./transform/tick-data";
2
2
 
3
3
  export * from "./utils";
4
4
 
5
- export * from "./algorithm";
5
+ export * from "./algorithm";
6
+
7
+ export * from "./spec";
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC","file":"index.js","sourcesContent":["export * from './transform/tick-data';\nexport * from './utils';\nexport * from './algorithm';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["export * from './transform/tick-data';\nexport * from './utils';\nexport * from './algorithm';\nexport * from './spec';\n"]}
@@ -0,0 +1 @@
1
+ export declare function cloneDeepSpec(spec: any, excludeKeys?: string[]): any;
@@ -0,0 +1,20 @@
1
+ import { isArray, isBoolean, isDate, isNumber, isString, isValid } from "@visactor/vutils";
2
+
3
+ import { isDataView, isHTMLElement } from "./common";
4
+
5
+ export function cloneDeepSpec(spec, excludeKeys = [ "data" ]) {
6
+ const value = spec;
7
+ let result;
8
+ if (!isValid(value) || "object" != typeof value) return value;
9
+ if (isDataView(value) || isHTMLElement(value)) return value;
10
+ const isArr = isArray(value), length = value.length;
11
+ result = isArr ? new Array(length) : "object" == typeof value ? {} : isBoolean(value) || isNumber(value) || isString(value) ? value : isDate(value) ? new Date(+value) : void 0;
12
+ const props = isArr ? void 0 : Object.keys(Object(value));
13
+ let index = -1;
14
+ if (result) for (;++index < (props || value).length; ) {
15
+ const key = props ? props[index] : index, subValue = value[key];
16
+ (null == excludeKeys ? void 0 : excludeKeys.includes(key.toString())) ? result[key] = subValue : result[key] = cloneDeepSpec(subValue, excludeKeys);
17
+ }
18
+ return result;
19
+ }
20
+ //# sourceMappingURL=clone-deep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/clone-deep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMrD,MAAM,UAAU,aAAa,CAAC,IAAS,EA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AC;YACzC,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACzC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;aACxB;iBAAM;gBACL,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;aACpD;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","file":"clone-deep.js","sourcesContent":["import { isArray, isBoolean, isDate, isNumber, isString, isValid } from '@visactor/vutils';\nimport { isDataView, isHTMLElement } from './common';\n\n/**\n * 深拷贝 spec,为避免循环引用,DataView 维持原有引用\n * @param spec 原spec\n */\nexport function cloneDeepSpec(spec: any, excludeKeys: string[] = ['data']) {\n const value = spec;\n\n let result;\n if (!isValid(value) || typeof value !== 'object') {\n return value;\n }\n\n // 判断是不是不能深拷贝的对象\n if (isDataView(value) || isHTMLElement(value)) {\n return value;\n }\n\n const isArr = isArray(value);\n const length = value.length;\n // 不考虑特殊数组的额外处理\n if (isArr) {\n result = new Array(length);\n }\n // 不考虑 buffer / arguments 类型的处理以及 prototype 的额外处理\n else if (typeof value === 'object') {\n result = {};\n }\n // 不建议使用作为 Boolean / Number / String 作为构造器\n else if (isBoolean(value) || isNumber(value) || isString(value)) {\n result = value;\n } else if (isDate(value)) {\n result = new Date(+value);\n }\n // 不考虑 ArrayBuffer / DataView / TypedArray / map / set / regexp / symbol 类型\n else {\n result = undefined;\n }\n\n // 不考虑 map / set / TypedArray 类型的赋值\n\n // 不考虑对象的 symbol 属性\n const props = isArr ? undefined : Object.keys(Object(value));\n\n let index = -1;\n if (result) {\n while (++index < (props || value).length) {\n const key = props ? props[index] : index;\n const subValue = value[key];\n if (excludeKeys?.includes(key.toString())) {\n result[key] = subValue;\n } else {\n result[key] = cloneDeepSpec(subValue, excludeKeys);\n }\n }\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { DataView } from '@visactor/vdataset';
2
+ export declare function isDataView(obj: any): obj is DataView;
3
+ export declare function isHTMLElement(obj: any): obj is Element;
@@ -0,0 +1,15 @@
1
+ import { DataView } from "@visactor/vdataset";
2
+
3
+ export function isDataView(obj) {
4
+ return obj instanceof DataView;
5
+ }
6
+
7
+ export function isHTMLElement(obj) {
8
+ try {
9
+ return obj instanceof Element;
10
+ } catch (_a) {
11
+ const htmlElementKeys = [ "children", "innerHTML", "classList", "setAttribute", "tagName", "getBoundingClientRect" ], keys = Object.keys(obj);
12
+ return htmlElementKeys.every((key => keys.includes(key)));
13
+ }
14
+ }
15
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,OAAO,GAAG,YAAY,QAAQ,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAQ;IACpC,IAAI;QACF,OAAO,GAAG,YAAY,OAAO,CAAC;KAC/B;IAAC,WAAM;QAEN,MAAM,eAAe,GAAsB;YACzC,UAAU;YACV,WAAW;YACX,WAAW;YACX,cAAc;YACd,SAAS;YACT,uBAAuB;SACxB,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;KACzD;AACH,CAAC","file":"common.js","sourcesContent":["import { DataView } from '@visactor/vdataset';\n\nexport function isDataView(obj: any): obj is DataView {\n return obj instanceof DataView;\n}\n\nexport function isHTMLElement(obj: any): obj is Element {\n try {\n return obj instanceof Element;\n } catch {\n // 跨端 plan B\n const htmlElementKeys: (keyof Element)[] = [\n 'children',\n 'innerHTML',\n 'classList',\n 'setAttribute',\n 'tagName',\n 'getBoundingClientRect'\n ];\n const keys = Object.keys(obj);\n return htmlElementKeys.every(key => keys.includes(key));\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './clone-deep';
2
+ export * from './common';
3
+ export * from './merge-spec';
@@ -0,0 +1,6 @@
1
+ export * from "./clone-deep";
2
+
3
+ export * from "./common";
4
+
5
+ export * from "./merge-spec";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC","file":"index.js","sourcesContent":["export * from './clone-deep';\nexport * from './common';\nexport * from './merge-spec';\n"]}
@@ -0,0 +1,5 @@
1
+ export declare function mergeSpec(target: any, ...sources: any[]): any;
2
+ export declare function mergeSpecWithFilter(target: any, filter: string | {
3
+ type: string;
4
+ index: number;
5
+ }, spec: any, forceMerge: boolean): void;
@@ -0,0 +1,57 @@
1
+ import { isArray, isArrayLike, isObject, isPlainObject, isValid } from "@visactor/vutils";
2
+
3
+ function baseMerge(target, source, shallowArray = !1) {
4
+ if (source) {
5
+ if (target === source) return;
6
+ if (isValid(source) && "object" == typeof source) {
7
+ const iterable = Object(source), props = [];
8
+ for (const key in iterable) props.push(key);
9
+ let {length: length} = props, propIndex = -1;
10
+ for (;length--; ) {
11
+ const key = props[++propIndex];
12
+ isValid(iterable[key]) && "object" == typeof iterable[key] && !isArray(target[key]) ? baseMergeDeep(target, source, key, shallowArray) : assignMergeValue(target, key, iterable[key]);
13
+ }
14
+ }
15
+ }
16
+ }
17
+
18
+ function baseMergeDeep(target, source, key, shallowArray = !1) {
19
+ const objValue = target[key], srcValue = source[key];
20
+ let newValue = source[key], isCommon = !0;
21
+ if (isArray(srcValue)) {
22
+ if (shallowArray) newValue = []; else if (isArray(objValue)) newValue = objValue; else if (isArrayLike(objValue)) {
23
+ newValue = new Array(objValue.length);
24
+ let index = -1;
25
+ const length = objValue.length;
26
+ for (;++index < length; ) newValue[index] = objValue[index];
27
+ }
28
+ } else isPlainObject(srcValue) ? (newValue = null != objValue ? objValue : {}, "function" != typeof objValue && "object" == typeof objValue || (newValue = {})) : isCommon = !1;
29
+ isCommon && baseMerge(newValue, srcValue, shallowArray), assignMergeValue(target, key, newValue);
30
+ }
31
+
32
+ function assignMergeValue(target, key, value) {
33
+ (void 0 !== value && !eq(target[key], value) || void 0 === value && !(key in target)) && (target[key] = value);
34
+ }
35
+
36
+ function eq(value, other) {
37
+ return value === other || Number.isNaN(value) && Number.isNaN(other);
38
+ }
39
+
40
+ export function mergeSpec(target, ...sources) {
41
+ let sourceIndex = -1;
42
+ const length = sources.length;
43
+ for (;++sourceIndex < length; ) {
44
+ baseMerge(target, sources[sourceIndex], !0);
45
+ }
46
+ return target;
47
+ }
48
+
49
+ export function mergeSpecWithFilter(target, filter, spec, forceMerge) {
50
+ Object.keys(target).forEach((k => {
51
+ if (isObject(filter)) filter.type === k && (isArray(target[k]) ? target[k].length >= filter.index && (target[k][filter.index] = forceMerge ? mergeSpec({}, target[k][filter.index], spec) : spec) : target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec); else if (isArray(target[k])) {
52
+ const index = target[k].findIndex((_s => _s.id === filter));
53
+ index >= 0 && (target[k][index] = forceMerge ? mergeSpec({}, target[k][index], spec) : spec);
54
+ } else target.id === filter && (target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec);
55
+ }));
56
+ }
57
+ //# sourceMappingURL=merge-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/merge-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE1F,SAAS,SAAS,CAAC,MAAW,EAAE,MAAW,E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,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;iBAChE;aACF;SACF;aAAM;YAEL,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;gBACtB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAA2B,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;gBACrF,IAAI,KAAK,IAAI,CAAC,EAAE;oBACd,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;iBAC9E;aACF;iBAAM,IAAI,MAAM,CAAC,EAAE,KAAK,MAAM,EAAE;gBAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;aAChE;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC","file":"merge-spec.js","sourcesContent":["import { isArray, isArrayLike, isObject, isPlainObject, isValid } from '@visactor/vutils';\n\nfunction baseMerge(target: any, source: any, shallowArray = false) {\n if (source) {\n if (target === source) {\n return;\n }\n if (isValid(source) && typeof source === 'object') {\n // baseFor\n const iterable = Object(source);\n const props = [];\n // keysIn\n for (const key in iterable) {\n props.push(key);\n }\n let { length } = props;\n let propIndex = -1;\n while (length--) {\n const key = props[++propIndex];\n if (\n isValid(iterable[key]) &&\n typeof iterable[key] === 'object' &&\n !isArray(target[key]) // VChart 特有逻辑\n ) {\n baseMergeDeep(target, source, key, shallowArray);\n } else {\n assignMergeValue(target, key, iterable[key]);\n }\n }\n }\n }\n}\n\n// 由于目前 VChart 内部对 spec 会先执行一次深拷贝,merge 暂时不考虑 source 中有环的问题\nfunction baseMergeDeep(target: object, source: object, key: string, shallowArray = false) {\n const objValue = target[key];\n const srcValue = source[key];\n let newValue = source[key];\n let isCommon = true;\n // 不考虑 buffer / typedArray 类型\n if (isArray(srcValue)) {\n if (shallowArray) {\n // 依据参数对数组做浅拷贝\n newValue = [];\n } else if (isArray(objValue)) {\n newValue = objValue;\n } else if (isArrayLike(objValue)) {\n // 如果 source 为数组,则 target 的 arrayLike 对象也视作为数组处理\n newValue = new Array(objValue.length);\n let index = -1;\n const length = objValue.length;\n while (++index < length) {\n newValue[index] = objValue[index];\n }\n }\n }\n // else if (isArray(srcValue) && shallowArray) {\n // newValue = [];\n // }\n // 不考虑 argument 类型\n else if (isPlainObject(srcValue)) {\n newValue = objValue ?? {};\n // 不考虑 prototype 的额外处理\n if (typeof objValue === 'function' || typeof objValue !== 'object') {\n newValue = {};\n }\n } else {\n isCommon = false;\n }\n // 对 class 等复杂对象或者浅拷贝的 array 不做拷贝处理\n if (isCommon) {\n baseMerge(newValue, srcValue, shallowArray);\n }\n assignMergeValue(target, key, newValue);\n}\n\nfunction assignMergeValue(target: object, key: string, value: any) {\n if ((value !== undefined && !eq(target[key], value)) || (value === undefined && !(key in target))) {\n // 不考虑 __proto__ 的赋值处理\n target[key] = value;\n }\n}\n\nfunction eq(value: any, other: any) {\n return value === other || (Number.isNaN(value) && Number.isNaN(other));\n}\n\n/* 与原生的 lodash merge 差异在于对数组是否应用最后一个 source 的结果\n * 以及对一些特殊情况的处理,比如对数组类型 padding 和对象类型的 padding 的 merge\n */\nexport function mergeSpec(target: any, ...sources: any[]): any {\n let sourceIndex = -1;\n const length = sources.length;\n while (++sourceIndex < length) {\n const source = sources[sourceIndex];\n baseMerge(target, source, true);\n }\n return target;\n}\n\nexport function mergeSpecWithFilter(\n target: any,\n filter: string | { type: string; index: number },\n spec: any,\n forceMerge: boolean\n) {\n Object.keys(target).forEach(k => {\n if (isObject(filter)) {\n if (filter.type === k) {\n if (isArray(target[k])) {\n if (target[k].length >= filter.index) {\n target[k][filter.index] = forceMerge ? mergeSpec({}, target[k][filter.index], spec) : spec;\n }\n } else {\n target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec;\n }\n }\n } else {\n // filter === user id\n if (isArray(target[k])) {\n const index = target[k].findIndex((_s: { id: string | number }) => _s.id === filter);\n if (index >= 0) {\n target[k][index] = forceMerge ? mergeSpec({}, target[k][index], spec) : spec;\n }\n } else if (target.id === filter) {\n target[k] = forceMerge ? mergeSpec({}, target[k], spec) : spec;\n }\n }\n });\n}\n"]}
@@ -88,5 +88,4 @@ const getStep = (domain, labelBoundsList, labelGap, labelLastVisible, defaultSte
88
88
  step: resultStep,
89
89
  delCount: resultDelCount
90
90
  };
91
- };
92
- //# sourceMappingURL=linear.js.map
91
+ };
@@ -25,6 +25,7 @@ export interface IPolarTickDataOpt extends ITickDataOpt {
25
25
  axisOrientType: IPolarOrientType;
26
26
  getRadius: () => number;
27
27
  labelOffset: number;
28
+ inside: boolean;
28
29
  }
29
30
  export interface ITickData {
30
31
  index: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/transform/tick-data/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import { ITextGraphicAttribute } from '@visactor/vrender-core';\n\nexport type CoordinateType = 'cartesian' | 'polar' | 'geo' | 'none';\nexport type IOrientType = 'left' | 'top' | 'right' | 'bottom' | 'z';\nexport type IPolarOrientType = 'radius' | 'angle';\n\nexport interface ITickDataOpt {\n /**\n * 是否进行轴采样\n */\n sampling?: boolean;\n tickCount?: number | ((option: ITickCallbackOption) => number);\n forceTickCount?: number;\n tickStep?: number;\n tickMode?: 'average' | 'd3' | string;\n noDecimals?: boolean;\n\n coordinateType: CoordinateType;\n axisOrientType: IOrientType | IPolarOrientType;\n startAngle?: number;\n\n labelFormatter?: (value: any) => string;\n labelStyle: ITextGraphicAttribute;\n labelGap?: number;\n}\n\nexport interface ICartesianTickDataOpt extends ITickDataOpt {\n axisOrientType: IOrientType;\n labelLastVisible: boolean;\n labelFlush: boolean;\n}\n\nexport interface IPolarTickDataOpt extends ITickDataOpt {\n axisOrientType: IPolarOrientType;\n getRadius: () => number;\n labelOffset: number;\n}\n\nexport interface ITickData {\n index: number;\n value: number | string;\n // label: string;\n}\n\ntype ITickCallbackOption = {\n /**\n * 坐标轴占据的画布大小。\n * 直角坐标系中为轴的宽度或高度。\n * 极坐标系中半径轴的长度。\n */\n axisLength?: number;\n /**\n * 轴标签的样式\n */\n labelStyle?: ITextGraphicAttribute;\n};\n"]}
1
+ {"version":3,"sources":["../src/transform/tick-data/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import { ITextGraphicAttribute } from '@visactor/vrender-core';\n\nexport type CoordinateType = 'cartesian' | 'polar' | 'geo' | 'none';\nexport type IOrientType = 'left' | 'top' | 'right' | 'bottom' | 'z';\nexport type IPolarOrientType = 'radius' | 'angle';\n\nexport interface ITickDataOpt {\n /**\n * 是否进行轴采样\n */\n sampling?: boolean;\n tickCount?: number | ((option: ITickCallbackOption) => number);\n forceTickCount?: number;\n tickStep?: number;\n tickMode?: 'average' | 'd3' | string;\n noDecimals?: boolean;\n\n coordinateType: CoordinateType;\n axisOrientType: IOrientType | IPolarOrientType;\n startAngle?: number;\n\n labelFormatter?: (value: any) => string;\n labelStyle: ITextGraphicAttribute;\n labelGap?: number;\n}\n\nexport interface ICartesianTickDataOpt extends ITickDataOpt {\n axisOrientType: IOrientType;\n labelLastVisible: boolean;\n labelFlush: boolean;\n}\n\nexport interface IPolarTickDataOpt extends ITickDataOpt {\n axisOrientType: IPolarOrientType;\n getRadius: () => number;\n labelOffset: number;\n inside: boolean;\n}\n\nexport interface ITickData {\n index: number;\n value: number | string;\n // label: string;\n}\n\ntype ITickCallbackOption = {\n /**\n * 坐标轴占据的画布大小。\n * 直角坐标系中为轴的宽度或高度。\n * 极坐标系中半径轴的长度。\n */\n axisLength?: number;\n /**\n * 轴标签的样式\n */\n labelStyle?: ITextGraphicAttribute;\n};\n"]}
@@ -1,8 +1,8 @@
1
- import { AABBBounds, degreeToRadian, polarToCartesian } from "@visactor/vutils";
1
+ import { AABBBounds, degreeToRadian } from "@visactor/vutils";
2
2
 
3
3
  import { initTextMeasure } from "../../utils/text";
4
4
 
5
- import { angleLabelOrientAttribute } from "../../utils/polar";
5
+ import { getLabelPosition } from "./utils/polar-label-position";
6
6
 
7
7
  export const convertDomainToTickData = domain => domain.map(((t, index) => ({
8
8
  index: index,
@@ -59,18 +59,19 @@ export const getCartesianLabelBounds = (scale, domain, op) => {
59
59
 
60
60
  export const getPolarAngleLabelBounds = (scale, domain, op) => {
61
61
  var _a;
62
- const {labelStyle: labelStyle, getRadius: getRadius, labelOffset: labelOffset, labelFormatter: labelFormatter} = op, radius = null == getRadius ? void 0 : getRadius(), labelAngle = null !== (_a = labelStyle.angle) && void 0 !== _a ? _a : 0, textMeasure = initTextMeasure(labelStyle);
63
- return domain.map((v => {
62
+ const {labelStyle: labelStyle, getRadius: getRadius, labelOffset: labelOffset, labelFormatter: labelFormatter, inside: inside} = op, radius = null == getRadius ? void 0 : getRadius(), labelAngle = null !== (_a = labelStyle.angle) && void 0 !== _a ? _a : 0, textMeasure = initTextMeasure(labelStyle), labelBoundsList = domain.map((v => {
63
+ var _a, _b;
64
64
  const str = labelFormatter ? labelFormatter(v) : `${v}`, {width: width, height: height} = textMeasure.quickMeasure(str), textWidth = Math.max(width, 12), textHeight = Math.max(height, 12), angle = scale.scale(v);
65
65
  let textX = 0, textY = 0;
66
- const orient = angleLabelOrientAttribute(angle), {x: x, y: y} = polarToCartesian({
66
+ const orient_align = null !== (_a = labelStyle.textAlign) && void 0 !== _a ? _a : "center", orient_baseline = null !== (_b = labelStyle.textBaseline) && void 0 !== _b ? _b : "middle", {x: x, y: y} = getLabelPosition(angle, {
67
67
  x: 0,
68
68
  y: 0
69
- }, radius + labelOffset, angle);
70
- textX = x + ("right" === orient.align ? -textWidth : "center" === orient.align ? -textWidth / 2 : 0),
71
- textY = y + ("bottom" === orient.baseline ? -textHeight : "middle" === orient.baseline ? -textHeight / 2 : 0);
69
+ }, radius, labelOffset, inside, str, labelStyle);
70
+ textX = x + ("right" === orient_align ? -textWidth : "center" === orient_align ? -textWidth / 2 : 0),
71
+ textY = y + ("bottom" === orient_baseline ? -textHeight : "middle" === orient_baseline ? -textHeight / 2 : 0);
72
72
  return (new AABBBounds).set(textX, textY, textX + textWidth, textY + textHeight).rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);
73
73
  }));
74
+ return labelBoundsList;
74
75
  };
75
76
 
76
77
  export const isAxisHorizontal = axisOrientType => [ "bottom", "top", "z" ].includes(axisOrientType);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/transform/tick-data/util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAa,EAAe,EAAE;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,KAAa,EAAE,EAAE;QACpD,OAAO;YACL,KAAK;YACL,KAAK,EAAE,CAAC;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAqB,EAAE,SAAqB,EAAE,GAAG,GAAG,CAAC,EAAW,EAAE;IAC7F,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,S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AAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAG9G,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE;aAC5B,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,GAAG,UAAU,CAAC;aACxD,MAAM,CAAC,UAAU,EAAE,KAAK,GAAG,SAAS,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC;QACrE,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,cAA2B,EAAE,EAAE;IAC9D,OAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAmB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAC5E,CAAC,CAAC","file":"util.js","sourcesContent":["import type { IBaseScale } from '@visactor/vscale';\nimport type { IBoundsLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { AABBBounds, degreeToRadian, polarToCartesian } from '@visactor/vutils';\nimport type { IGraphic, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\nimport { initTextMeasure } from '../../utils/text';\nimport { angleLabelOrientAttribute } from '../../utils/polar';\nimport type { ICartesianTickDataOpt, IOrientType, IPolarTickDataOpt, ITickData } from './interface';\n\nexport const convertDomainToTickData = (domain: any[]): ITickData[] => {\n const ticks = domain.map((t: number, index: number) => {\n return {\n index,\n value: t\n };\n });\n return ticks;\n};\n\n/** 判断两个label是否有重叠情况 */\nexport const labelOverlap = (prevLabel: AABBBounds, nextLabel: AABBBounds, gap = 0): boolean => {\n const prevBounds = new AABBBounds(prevLabel).expand(gap / 2);\n const nextBounds = new AABBBounds(nextLabel).expand(gap / 2);\n return prevBounds.intersects(nextBounds);\n};\n\n/** 判断两个不相交的label相隔的距离 */\nexport const labelDistance = (prevLabel: AABBBounds, nextLabel: AABBBounds): [number, number] => {\n let horizontal = 0;\n if (prevLabel.x2 < nextLabel.x1) {\n horizontal = nextLabel.x1 - prevLabel.x2;\n } else if (nextLabel.x2 < prevLabel.x1) {\n horizontal = prevLabel.x1 - nextLabel.x2;\n }\n\n let vertical = 0;\n if (prevLabel.y2 < nextLabel.y1) {\n vertical = nextLabel.y1 - prevLabel.y2;\n } else if (nextLabel.y2 < prevLabel.y1) {\n vertical = prevLabel.y1 - nextLabel.y2;\n }\n\n return [horizontal, vertical];\n};\n\nexport function intersect(a: IBoundsLike, b: IBoundsLike, sep: number) {\n return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);\n}\n\nexport interface ILabelItem<T> extends Pick<IGraphic, 'AABBBounds'> {\n value?: T;\n}\n\nexport function hasOverlap<T>(items: ILabelItem<T>[], pad: number): boolean {\n for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {\n b = items[i];\n if (intersect(a.AABBBounds, b.AABBBounds, pad)) {\n return true;\n }\n }\n return false;\n}\n\nexport const MIN_TICK_GAP = 12;\n\nexport const getCartesianLabelBounds = (scale: IBaseScale, domain: any[], op: ICartesianTickDataOpt): AABBBounds[] => {\n const { labelStyle, axisOrientType, labelFlush, labelFormatter, startAngle = 0 } = op;\n let labelAngle = labelStyle.angle ?? 0;\n if (labelStyle.direction === 'vertical') {\n labelAngle += degreeToRadian(90);\n }\n const isHorizontal = ['bottom', 'top'].includes(axisOrientType);\n const isVertical = ['left', 'right'].includes(axisOrientType);\n let scaleX = 1;\n let scaleY = 0;\n if (isHorizontal) {\n // nothing to update\n } else if (isVertical) {\n scaleX = 0;\n scaleY = 1;\n } else if (startAngle) {\n scaleX = Math.cos(startAngle);\n scaleY = -Math.sin(startAngle);\n }\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any, i: number) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const pos = scale.scale(v);\n const baseTextX = scaleX * pos;\n const baseTextY = scaleY * pos;\n let textX = baseTextX;\n let textY = baseTextY;\n\n let align: TextAlignType;\n if (labelFlush && isHorizontal && i === 0) {\n align = 'left';\n } else if (labelFlush && isHorizontal && i === domain.length - 1) {\n align = 'right';\n } else {\n align = labelStyle.textAlign ?? 'center';\n }\n if (align === 'right') {\n textX -= textWidth;\n } else if (align === 'center') {\n textX -= textWidth / 2;\n }\n\n let baseline: TextBaselineType;\n if (labelFlush && isVertical && i === 0) {\n baseline = 'top';\n } else if (labelFlush && isVertical && i === domain.length - 1) {\n baseline = 'bottom';\n } else {\n baseline = labelStyle.textBaseline ?? 'middle';\n }\n if (baseline === 'bottom') {\n textY -= textHeight;\n } else if (baseline === 'middle') {\n textY -= textHeight / 2;\n }\n\n // 计算 label 包围盒\n const bounds = new AABBBounds().set(textX, textY, textX + textWidth, textY + textHeight);\n\n if (labelAngle) {\n bounds.rotate(labelAngle, baseTextX, baseTextY);\n }\n\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const getPolarAngleLabelBounds = (scale: IBaseScale, domain: any[], op: IPolarTickDataOpt): AABBBounds[] => {\n const { labelStyle, getRadius, labelOffset, labelFormatter } = op;\n const radius = getRadius?.();\n const labelAngle = labelStyle.angle ?? 0;\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const angle = scale.scale(v);\n let textX = 0;\n let textY = 0;\n const orient = angleLabelOrientAttribute(angle);\n const { x, y } = polarToCartesian({ x: 0, y: 0 }, radius + labelOffset, angle);\n textX = x + (orient.align === 'right' ? -textWidth : orient.align === 'center' ? -textWidth / 2 : 0);\n textY = y + (orient.baseline === 'bottom' ? -textHeight : orient.baseline === 'middle' ? -textHeight / 2 : 0);\n\n // 计算 label 包围盒\n const bounds = new AABBBounds()\n .set(textX, textY, textX + textWidth, textY + textHeight)\n .rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const isAxisHorizontal = (axisOrientType: IOrientType) => {\n return (['bottom', 'top', 'z'] as IOrientType[]).includes(axisOrientType);\n};\n"]}
1
+ {"version":3,"sources":["../src/transform/tick-data/util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAa,EAAe,EAAE;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,KAAa,EAAE,EAAE;QACpD,OAAO;YACL,KAAK;YACL,KAAK,EAAE,CAAC;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAqB,EAAE,SAAqB,EAAE,GAAG,GAAG,CAAC,EAAW,EAAE;IAC7F,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,OAAO,UAAU,CAAC,UAAU,CAAC,UA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UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAG9G,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE;aAC5B,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,GAAG,UAAU,CAAC;aACxD,MAAM,CAAC,UAAU,EAAE,KAAK,GAAG,SAAS,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC;QACrE,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,cAA2B,EAAE,EAAE;IAC9D,OAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAmB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAC5E,CAAC,CAAC","file":"util.js","sourcesContent":["import type { IBaseScale } from '@visactor/vscale';\nimport type { IBoundsLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { AABBBounds, degreeToRadian } from '@visactor/vutils';\nimport type { IGraphic, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\nimport { initTextMeasure } from '../../utils/text';\nimport type { ICartesianTickDataOpt, IOrientType, IPolarTickDataOpt, ITickData } from './interface';\nimport { getLabelPosition } from './utils/polar-label-position';\n\nexport const convertDomainToTickData = (domain: any[]): ITickData[] => {\n const ticks = domain.map((t: number, index: number) => {\n return {\n index,\n value: t\n };\n });\n return ticks;\n};\n\n/** 判断两个label是否有重叠情况 */\nexport const labelOverlap = (prevLabel: AABBBounds, nextLabel: AABBBounds, gap = 0): boolean => {\n const prevBounds = new AABBBounds(prevLabel).expand(gap / 2);\n const nextBounds = new AABBBounds(nextLabel).expand(gap / 2);\n return prevBounds.intersects(nextBounds);\n};\n\n/** 判断两个不相交的label相隔的距离 */\nexport const labelDistance = (prevLabel: AABBBounds, nextLabel: AABBBounds): [number, number] => {\n let horizontal = 0;\n if (prevLabel.x2 < nextLabel.x1) {\n horizontal = nextLabel.x1 - prevLabel.x2;\n } else if (nextLabel.x2 < prevLabel.x1) {\n horizontal = prevLabel.x1 - nextLabel.x2;\n }\n\n let vertical = 0;\n if (prevLabel.y2 < nextLabel.y1) {\n vertical = nextLabel.y1 - prevLabel.y2;\n } else if (nextLabel.y2 < prevLabel.y1) {\n vertical = prevLabel.y1 - nextLabel.y2;\n }\n\n return [horizontal, vertical];\n};\n\nexport function intersect(a: IBoundsLike, b: IBoundsLike, sep: number) {\n return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);\n}\n\nexport interface ILabelItem<T> extends Pick<IGraphic, 'AABBBounds'> {\n value?: T;\n}\n\nexport function hasOverlap<T>(items: ILabelItem<T>[], pad: number): boolean {\n for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {\n b = items[i];\n if (intersect(a.AABBBounds, b.AABBBounds, pad)) {\n return true;\n }\n }\n return false;\n}\n\nexport const MIN_TICK_GAP = 12;\n\nexport const getCartesianLabelBounds = (scale: IBaseScale, domain: any[], op: ICartesianTickDataOpt): AABBBounds[] => {\n const { labelStyle, axisOrientType, labelFlush, labelFormatter, startAngle = 0 } = op;\n let labelAngle = labelStyle.angle ?? 0;\n if (labelStyle.direction === 'vertical') {\n labelAngle += degreeToRadian(90);\n }\n const isHorizontal = ['bottom', 'top'].includes(axisOrientType);\n const isVertical = ['left', 'right'].includes(axisOrientType);\n let scaleX = 1;\n let scaleY = 0;\n if (isHorizontal) {\n // nothing to update\n } else if (isVertical) {\n scaleX = 0;\n scaleY = 1;\n } else if (startAngle) {\n scaleX = Math.cos(startAngle);\n scaleY = -Math.sin(startAngle);\n }\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any, i: number) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const pos = scale.scale(v);\n const baseTextX = scaleX * pos;\n const baseTextY = scaleY * pos;\n let textX = baseTextX;\n let textY = baseTextY;\n\n let align: TextAlignType;\n if (labelFlush && isHorizontal && i === 0) {\n align = 'left';\n } else if (labelFlush && isHorizontal && i === domain.length - 1) {\n align = 'right';\n } else {\n align = labelStyle.textAlign ?? 'center';\n }\n if (align === 'right') {\n textX -= textWidth;\n } else if (align === 'center') {\n textX -= textWidth / 2;\n }\n\n let baseline: TextBaselineType;\n if (labelFlush && isVertical && i === 0) {\n baseline = 'top';\n } else if (labelFlush && isVertical && i === domain.length - 1) {\n baseline = 'bottom';\n } else {\n baseline = labelStyle.textBaseline ?? 'middle';\n }\n if (baseline === 'bottom') {\n textY -= textHeight;\n } else if (baseline === 'middle') {\n textY -= textHeight / 2;\n }\n\n // 计算 label 包围盒\n const bounds = new AABBBounds().set(textX, textY, textX + textWidth, textY + textHeight);\n\n if (labelAngle) {\n bounds.rotate(labelAngle, baseTextX, baseTextY);\n }\n\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const getPolarAngleLabelBounds = (scale: IBaseScale, domain: any[], op: IPolarTickDataOpt): AABBBounds[] => {\n const { labelStyle, getRadius, labelOffset, labelFormatter, inside } = op;\n const radius = getRadius?.();\n const labelAngle = labelStyle.angle ?? 0;\n\n const textMeasure = initTextMeasure(labelStyle);\n const labelBoundsList = domain.map((v: any) => {\n const str = labelFormatter ? labelFormatter(v) : `${v}`;\n\n // 估算文本宽高\n const { width, height } = textMeasure.quickMeasure(str);\n const textWidth = Math.max(width, MIN_TICK_GAP);\n const textHeight = Math.max(height, MIN_TICK_GAP);\n\n // 估算文本位置\n const angle = scale.scale(v);\n let textX = 0;\n let textY = 0;\n const orient = {\n align: labelStyle.textAlign ?? 'center',\n baseline: labelStyle.textBaseline ?? 'middle'\n };\n\n const { x, y } = getLabelPosition(angle, { x: 0, y: 0 }, radius, labelOffset, inside, str, labelStyle);\n textX = x + (orient.align === 'right' ? -textWidth : orient.align === 'center' ? -textWidth / 2 : 0);\n textY = y + (orient.baseline === 'bottom' ? -textHeight : orient.baseline === 'middle' ? -textHeight / 2 : 0);\n\n // 计算 label 包围盒\n const bounds = new AABBBounds()\n .set(textX, textY, textX + textWidth, textY + textHeight)\n .rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);\n return bounds;\n });\n\n return labelBoundsList;\n};\n\nexport const isAxisHorizontal = (axisOrientType: IOrientType) => {\n return (['bottom', 'top', 'z'] as IOrientType[]).includes(axisOrientType);\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import { ITextGraphicAttribute } from '@visactor/vrender-core';
2
+ export declare function getLabelPosition(angle: number, center: {
3
+ x: number;
4
+ y: number;
5
+ }, radius: number, labelOffset: number, inside: boolean, text: string | number, style: Partial<ITextGraphicAttribute>): {
6
+ x: number;
7
+ y: number;
8
+ };
@@ -0,0 +1,12 @@
1
+ import { getCircleLabelPosition, getCircleVerticalVector, getVerticalCoord } from "@visactor/vrender-components";
2
+
3
+ import { polarToCartesian } from "@visactor/vutils";
4
+
5
+ export function getLabelPosition(angle, center, radius, labelOffset, inside, text, style) {
6
+ const point = polarToCartesian({
7
+ x: 0,
8
+ y: 0
9
+ }, radius, angle), labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside)), vector = getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside);
10
+ return getCircleLabelPosition(labelPoint, vector, text, style);
11
+ }
12
+ //# sourceMappingURL=polar-label-position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/transform/tick-data/utils/polar-label-position.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,UAAU,gBAAgB,CAC9B,KAAa,EACb,MAAgC,EAChC,MAAc,EACd,WAAmB,EACnB,MAAe,EACf,IAAqB,EACrB,KAAqC;IAErC,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,EAAE,uBAAuB,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxG,MAAM,MAAM,GAAG,uBAAuB,CAAC,WAAW,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrF,OAAO,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC","file":"polar-label-position.js","sourcesContent":["import { ITextGraphicAttribute } from '@visactor/vrender-core';\nimport { getCircleLabelPosition, getCircleVerticalVector, getVerticalCoord } from '@visactor/vrender-components';\nimport { polarToCartesian } from '@visactor/vutils';\n\nexport function getLabelPosition(\n angle: number,\n center: { x: number; y: number },\n radius: number,\n labelOffset: number,\n inside: boolean,\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n) {\n const point = polarToCartesian({ x: 0, y: 0 }, radius, angle);\n const labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside));\n const vector = getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside);\n return getCircleLabelPosition(labelPoint, vector, text, style);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vutils-extension",
3
- "version": "1.11.0-alpha.2",
3
+ "version": "1.11.0",
4
4
  "description": "The extension module for VUtil from VisActor",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -11,13 +11,18 @@
11
11
  "es",
12
12
  "dist"
13
13
  ],
14
+ "peerDependencies": {
15
+ "@visactor/vrender-core": ">=0.18",
16
+ "@visactor/vrender-components": ">=0.18"
17
+ },
14
18
  "dependencies": {
15
- "@visactor/vutils": "~0.18.1",
16
- "@visactor/vscale": "~0.18.1",
17
- "@visactor/vrender-core": "0.18.7",
18
- "@visactor/vrender-kits": "0.18.7"
19
+ "@visactor/vutils": "~0.18.6",
20
+ "@visactor/vdataset": "~0.18.6",
21
+ "@visactor/vscale": "~0.18.6"
19
22
  },
20
23
  "devDependencies": {
24
+ "@visactor/vrender-core": "0.19.0",
25
+ "@visactor/vrender-components": "0.19.0",
21
26
  "@rushstack/eslint-patch": "~1.1.4",
22
27
  "eslint": "~8.18.0",
23
28
  "vite": "3.2.6",
@@ -38,8 +43,8 @@
38
43
  "tslib": "2.3.1",
39
44
  "tslint": "5.12.1",
40
45
  "@internal/bundler": "0.0.1",
41
- "@internal/ts-config": "0.0.1",
42
- "@internal/eslint-config": "0.0.1"
46
+ "@internal/eslint-config": "0.0.1",
47
+ "@internal/ts-config": "0.0.1"
43
48
  },
44
49
  "publishConfig": {
45
50
  "access": "public"