@visactor/vrender-components 0.14.9-alpha.1 → 0.14.9-alpha.4
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/axis/animate/group-transition.d.ts +2 -1
- package/cjs/axis/animate/group-transition.js +3 -3
- package/cjs/axis/animate/group-transition.js.map +1 -1
- package/cjs/axis/base.d.ts +5 -8
- package/cjs/axis/base.js +16 -32
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +3 -23
- package/cjs/axis/circle.js +3 -84
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/config.d.ts +0 -17
- package/cjs/axis/config.js +0 -17
- package/cjs/axis/config.js.map +1 -1
- package/cjs/axis/grid/base.d.ts +24 -0
- package/cjs/axis/{grid.js → grid/base.js} +67 -20
- package/cjs/axis/grid/base.js.map +1 -0
- package/cjs/axis/grid/circle.d.ts +9 -0
- package/cjs/axis/grid/circle.js +92 -0
- package/cjs/axis/grid/circle.js.map +1 -0
- package/cjs/axis/grid/index.d.ts +3 -0
- package/cjs/axis/grid/index.js +22 -0
- package/cjs/axis/grid/index.js.map +1 -0
- package/cjs/axis/grid/line.d.ts +10 -0
- package/cjs/axis/grid/line.js +103 -0
- package/cjs/axis/grid/line.js.map +1 -0
- package/cjs/axis/grid/type.d.ts +63 -0
- package/cjs/axis/grid/type.js +6 -0
- package/cjs/axis/grid/type.js.map +1 -0
- package/cjs/axis/index.d.ts +0 -1
- package/cjs/axis/index.js +3 -3
- package/cjs/axis/index.js.map +1 -1
- package/cjs/axis/line.d.ts +3 -24
- package/cjs/axis/line.js +17 -118
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/mixin/circle.d.ts +17 -0
- package/cjs/axis/mixin/circle.js +30 -0
- package/cjs/axis/mixin/circle.js.map +1 -0
- package/cjs/axis/mixin/line.d.ts +14 -0
- package/cjs/axis/mixin/line.js +32 -0
- package/cjs/axis/mixin/line.js.map +1 -0
- package/cjs/axis/type.d.ts +0 -55
- package/cjs/axis/type.js.map +1 -1
- package/cjs/core/base.d.ts +2 -1
- package/cjs/core/base.js +4 -2
- package/cjs/core/base.js.map +1 -1
- package/cjs/core/type.js +2 -1
- package/cjs/crosshair/base.js +1 -2
- package/cjs/index.d.ts +3 -1
- package/cjs/index.js +9 -8
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/type.js +2 -1
- package/cjs/jsx/component-type.d.ts +4 -0
- package/cjs/jsx/component-type.js +13 -0
- package/cjs/jsx/component-type.js.map +1 -0
- package/cjs/jsx/index.d.ts +1 -0
- package/cjs/jsx/index.js +21 -0
- package/cjs/jsx/index.js.map +1 -0
- package/cjs/label/arc.js +5 -4
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.js +4 -2
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/type.d.ts +4 -3
- package/cjs/label/type.js.map +1 -1
- package/cjs/legend/discrete/discrete.js +28 -27
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/link-path/index.js +1 -2
- package/cjs/link-path/link-path.js +2 -1
- package/cjs/marker/point.js +1 -1
- package/cjs/pager/pager.js +4 -2
- package/cjs/pager/pager.js.map +1 -1
- package/cjs/poptip/register.d.ts +1 -1
- package/cjs/poptip/register.js +8 -6
- package/cjs/poptip/register.js.map +1 -1
- package/cjs/util/matrix.d.ts +1 -1
- package/cjs/util/matrix.js.map +1 -1
- package/cjs/util/text.js +3 -3
- package/cjs/util/text.js.map +1 -1
- package/dist/index.js +684 -634
- package/dist/index.min.js +1 -1
- package/es/axis/animate/group-transition.d.ts +2 -1
- package/es/axis/animate/group-transition.js +3 -3
- package/es/axis/animate/group-transition.js.map +1 -1
- package/es/axis/base.d.ts +5 -8
- package/es/axis/base.js +15 -33
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +3 -23
- package/es/axis/circle.js +4 -85
- package/es/axis/circle.js.map +1 -1
- package/es/axis/config.d.ts +0 -17
- package/es/axis/config.js +0 -17
- package/es/axis/config.js.map +1 -1
- package/es/axis/grid/base.d.ts +24 -0
- package/es/axis/{grid.js → grid/base.js} +69 -21
- package/es/axis/grid/base.js.map +1 -0
- package/es/axis/grid/circle.d.ts +9 -0
- package/es/axis/grid/circle.js +92 -0
- package/es/axis/grid/circle.js.map +1 -0
- package/es/axis/grid/index.d.ts +3 -0
- package/es/axis/grid/index.js +6 -0
- package/es/axis/grid/index.js.map +1 -0
- package/es/axis/grid/line.d.ts +10 -0
- package/es/axis/grid/line.js +102 -0
- package/es/axis/grid/line.js.map +1 -0
- package/es/axis/grid/type.d.ts +63 -0
- package/es/axis/grid/type.js +2 -0
- package/es/axis/grid/type.js.map +1 -0
- package/es/axis/index.d.ts +0 -1
- package/es/axis/index.js +0 -2
- package/es/axis/index.js.map +1 -1
- package/es/axis/line.d.ts +3 -24
- package/es/axis/line.js +9 -110
- package/es/axis/line.js.map +1 -1
- package/es/axis/mixin/circle.d.ts +17 -0
- package/es/axis/mixin/circle.js +25 -0
- package/es/axis/mixin/circle.js.map +1 -0
- package/es/axis/mixin/line.d.ts +14 -0
- package/es/axis/mixin/line.js +23 -0
- package/es/axis/mixin/line.js.map +1 -0
- package/es/axis/type.d.ts +0 -55
- package/es/axis/type.js.map +1 -1
- package/es/core/base.d.ts +2 -1
- package/es/core/base.js +3 -3
- package/es/core/base.js.map +1 -1
- package/es/core/type.js +2 -1
- package/es/crosshair/base.js +1 -2
- package/es/index.d.ts +3 -1
- package/es/index.js +5 -1
- package/es/index.js.map +1 -1
- package/es/indicator/type.js +2 -1
- package/es/jsx/component-type.d.ts +4 -0
- package/es/jsx/component-type.js +5 -0
- package/es/jsx/component-type.js.map +1 -0
- package/es/jsx/index.d.ts +1 -0
- package/es/jsx/index.js +2 -0
- package/es/jsx/index.js.map +1 -0
- package/es/label/arc.js +5 -4
- package/es/label/arc.js.map +1 -1
- package/es/label/base.js +4 -2
- package/es/label/base.js.map +1 -1
- package/es/label/type.d.ts +4 -3
- package/es/label/type.js.map +1 -1
- package/es/legend/discrete/discrete.js +26 -25
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/link-path/index.js +1 -2
- package/es/link-path/link-path.js +2 -1
- package/es/marker/point.js +1 -1
- package/es/pager/pager.js +4 -2
- package/es/pager/pager.js.map +1 -1
- package/es/poptip/register.d.ts +1 -1
- package/es/poptip/register.js +7 -6
- package/es/poptip/register.js.map +1 -1
- package/es/util/matrix.d.ts +1 -1
- package/es/util/matrix.js.map +1 -1
- package/es/util/text.js +3 -3
- package/es/util/text.js.map +1 -1
- package/package.json +2 -2
- package/cjs/axis/grid.d.ts +0 -9
- package/cjs/axis/grid.js.map +0 -1
- package/es/axis/grid.d.ts +0 -9
- package/es/axis/grid.js.map +0 -1
package/cjs/poptip/register.js
CHANGED
|
@@ -6,17 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
const vrender_1 = require("@visactor/vrender"), inversify_1 = require("inversify"), vutils_1 = require("@visactor/vutils"), contribution_1 = require("./contribution"), poptip_plugin_1 = require("./poptip-plugin"), theme_1 = require("./theme");
|
|
8
8
|
|
|
9
|
-
function loadPoptip(
|
|
10
|
-
|
|
9
|
+
function loadPoptip() {
|
|
10
|
+
vrender_1.container.load(exports.popTipModule);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function setPoptipTheme(defaultPoptipTheme) {
|
|
14
14
|
(0, vutils_1.merge)(theme_1.theme.poptip, theme_1.DEFAULT_THEME, defaultPoptipTheme);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
exports.popTipModule = new inversify_1.ContainerModule((bind => {
|
|
18
|
-
bind(contribution_1.PopTipRenderContribution).toSelf().inSingletonScope(),
|
|
19
|
-
bind(
|
|
20
|
-
|
|
17
|
+
exports.popTipModule = new inversify_1.ContainerModule(((bind, unbind, isBound, rebind) => {
|
|
18
|
+
isBound(contribution_1.PopTipRenderContribution) || (bind(contribution_1.PopTipRenderContribution).toSelf().inSingletonScope(),
|
|
19
|
+
bind(vrender_1.InteractiveSubRenderContribution).toService(contribution_1.PopTipRenderContribution)),
|
|
20
|
+
isBound(poptip_plugin_1.PopTipPlugin) || (bind(poptip_plugin_1.PopTipPlugin).toSelf(),
|
|
21
|
+
bind(vrender_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipPlugin)), isBound(poptip_plugin_1.PopTipForClipedTextPlugin) || (bind(poptip_plugin_1.PopTipForClipedTextPlugin).toSelf(),
|
|
22
|
+
bind(vrender_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipForClipedTextPlugin));
|
|
21
23
|
})), exports.loadPoptip = loadPoptip, exports.setPoptipTheme = setPoptipTheme;
|
|
22
24
|
//# sourceMappingURL=register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":";;;AAAA,+CAAmG;AACnG,yCAA4C;AAC5C,6CAAyC;AACzC,iDAA0D;AAC1D,mDAA0E;AAE1E,mCAA+C;AAElC,QAAA,YAAY,GAAG,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;
|
|
1
|
+
{"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":";;;AAAA,+CAAmG;AACnG,yCAA4C;AAC5C,6CAAyC;AACzC,iDAA0D;AAC1D,mDAA0E;AAE1E,mCAA+C;AAElC,QAAA,YAAY,GAAG,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAChF,IAAI,CAAC,OAAO,CAAC,uCAAwB,CAAC,EAAE;QACtC,IAAI,CAAC,uCAAwB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAC3D,IAAI,CAAC,0CAAgC,CAAC,CAAC,SAAS,CAAC,uCAAwB,CAAC,CAAC;KAC5E;IACD,IAAI,CAAC,OAAO,CAAC,4BAAY,CAAC,EAAE;QAC1B,IAAI,CAAC,4BAAY,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,2BAAiB,CAAC,CAAC,SAAS,CAAC,4BAAY,CAAC,CAAC;KACjD;IACD,IAAI,CAAC,OAAO,CAAC,yCAAyB,CAAC,EAAE;QACvC,IAAI,CAAC,yCAAyB,CAAC,CAAC,MAAM,EAAE,CAAC;QACzC,IAAI,CAAC,2BAAiB,CAAC,CAAC,SAAS,CAAC,yCAAyB,CAAC,CAAC;KAC9D;AACH,CAAC,CAAC,CAAC;AAEH,SAAgB,UAAU;IACxB,mBAAS,CAAC,IAAI,CAAC,oBAAY,CAAC,CAAC;AAC/B,CAAC;AAFD,gCAEC;AAED,SAAgB,cAAc,CAAC,kBAAoC;IACjE,IAAA,cAAK,EAAC,aAAK,CAAC,MAAM,EAAE,qBAAa,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAFD,wCAEC","file":"register.js","sourcesContent":["import { container, InteractiveSubRenderContribution, AutoEnablePlugins } from '@visactor/vrender';\nimport { ContainerModule } from 'inversify';\nimport { merge } from '@visactor/vutils';\nimport { PopTipRenderContribution } from './contribution';\nimport { PopTipPlugin, PopTipForClipedTextPlugin } from './poptip-plugin';\nimport type { PopTipAttributes } from './type';\nimport { DEFAULT_THEME, theme } from './theme';\n\nexport const popTipModule = new ContainerModule((bind, unbind, isBound, rebind) => {\n if (!isBound(PopTipRenderContribution)) {\n bind(PopTipRenderContribution).toSelf().inSingletonScope();\n bind(InteractiveSubRenderContribution).toService(PopTipRenderContribution);\n }\n if (!isBound(PopTipPlugin)) {\n bind(PopTipPlugin).toSelf();\n bind(AutoEnablePlugins).toService(PopTipPlugin);\n }\n if (!isBound(PopTipForClipedTextPlugin)) {\n bind(PopTipForClipedTextPlugin).toSelf();\n bind(AutoEnablePlugins).toService(PopTipForClipedTextPlugin);\n }\n});\n\nexport function loadPoptip() {\n container.load(popTipModule);\n}\n\nexport function setPoptipTheme(defaultPoptipTheme: PopTipAttributes) {\n merge(theme.poptip, DEFAULT_THEME, defaultPoptipTheme);\n}\n"]}
|
package/cjs/util/matrix.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type Vector2 = [number, number];
|
|
2
|
-
export declare function scale(vector: Vector2, scale: number): number
|
|
2
|
+
export declare function scale(vector: Vector2, scale: number): [number, number];
|
|
3
3
|
export declare function length(vector: Vector2): number;
|
|
4
4
|
export declare function normalize(vector: Vector2): number[];
|
|
5
5
|
export declare function angle(vector1: Vector2, vector2: Vector2): number;
|
package/cjs/util/matrix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/util/matrix.ts"],"names":[],"mappings":";;;AAKA,SAAgB,KAAK,CAAC,MAAe,EAAE,KAAa;IAClD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAChD,CAAC;AAFD,sBAEC;AAKD,SAAgB,MAAM,CAAC,MAAe;IACpC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC,CAAC;AAHD,wBAGC;AAKD,SAAgB,SAAS,CAAC,MAAe;IACvC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;IACtB,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,GAAG,GAAG,CAAC,EAAE;QACX,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC1B;IACD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AAC5C,CAAC;AAPD,8BAOC;AAKD,SAAgB,KAAK,CAAC,OAAgB,EAAE,OAAgB;IACtD,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AAC3B,CAAC;AAdD,0BAcC","file":"matrix.js","sourcesContent":["export type Vector2 = [number, number];\n\n/**\n * Scales a vec2 by a scalar number\n */\nexport function scale(vector: Vector2, scale: number) {\n return [vector[0] * scale, vector[1] * scale];\n}\n\n/**\n * Calculates the length of a vec2\n */\nexport function length(vector: Vector2) {\n const [x, y] = vector;\n return Math.sqrt(x * x + y * y);\n}\n\n/**\n * Normalize a vec2\n */\nexport function normalize(vector: Vector2) {\n const [x, y] = vector;\n let len = x * x + y * y;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n return [vector[0] * len, vector[1] * len];\n}\n\n/**\n * Get the angle between two 2D vectors\n */\nexport function angle(vector1: Vector2, vector2: Vector2) {\n const [x1, y1] = vector1;\n const [x2, y2] = vector2;\n const mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));\n const cosine = mag && (x1 * x2 + y1 * y2) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n\n/**\n * 向量 v1 到 向量 v2 夹角的方向\n * @param {Array} v1 向量\n * @param {Array} v2 向量\n * @return {Boolean} >= 0 顺时针 < 0 逆时针\n */\nexport function direction(v1: number[], v2: number[]): number {\n return v1[0] * v2[1] - v2[0] * v1[1];\n}\n\n/**\n * 二维向量 v1 到 v2 的夹角\n * @param v1\n * @param v2\n * @param direct\n */\nexport function angleTo(v1: [number, number], v2: [number, number], direct: boolean): number {\n const ang = angle(v1, v2);\n const angleLargeThanPI = direction(v1, v2) >= 0;\n if (direct) {\n if (angleLargeThanPI) {\n return Math.PI * 2 - ang;\n }\n return ang;\n }\n\n if (angleLargeThanPI) {\n return ang;\n }\n return Math.PI * 2 - ang;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/util/matrix.ts"],"names":[],"mappings":";;;AAKA,SAAgB,KAAK,CAAC,MAAe,EAAE,KAAa;IAClD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC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CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAND,sBAMC;AAQD,SAAgB,SAAS,CAAC,EAAY,EAAE,EAAY;IAClD,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAFD,8BAEC;AAQD,SAAgB,OAAO,CAAC,EAAoB,EAAE,EAAoB,EAAE,MAAe;IACjF,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1B,MAAM,gBAAgB,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,MAAM,EAAE;QACV,IAAI,gBAAgB,EAAE;YACpB,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;SAC1B;QACD,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,gBAAgB,EAAE;QACpB,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC;AAdD,0BAcC","file":"matrix.js","sourcesContent":["export type Vector2 = [number, number];\n\n/**\n * Scales a vec2 by a scalar number\n */\nexport function scale(vector: Vector2, scale: number): [number, number] {\n return [vector[0] * scale, vector[1] * scale];\n}\n\n/**\n * Calculates the length of a vec2\n */\nexport function length(vector: Vector2) {\n const [x, y] = vector;\n return Math.sqrt(x * x + y * y);\n}\n\n/**\n * Normalize a vec2\n */\nexport function normalize(vector: Vector2) {\n const [x, y] = vector;\n let len = x * x + y * y;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n return [vector[0] * len, vector[1] * len];\n}\n\n/**\n * Get the angle between two 2D vectors\n */\nexport function angle(vector1: Vector2, vector2: Vector2) {\n const [x1, y1] = vector1;\n const [x2, y2] = vector2;\n const mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));\n const cosine = mag && (x1 * x2 + y1 * y2) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n\n/**\n * 向量 v1 到 向量 v2 夹角的方向\n * @param {Array} v1 向量\n * @param {Array} v2 向量\n * @return {Boolean} >= 0 顺时针 < 0 逆时针\n */\nexport function direction(v1: number[], v2: number[]): number {\n return v1[0] * v2[1] - v2[0] * v1[1];\n}\n\n/**\n * 二维向量 v1 到 v2 的夹角\n * @param v1\n * @param v2\n * @param direct\n */\nexport function angleTo(v1: [number, number], v2: [number, number], direct: boolean): number {\n const ang = angle(v1, v2);\n const angleLargeThanPI = direction(v1, v2) >= 0;\n if (direct) {\n if (angleLargeThanPI) {\n return Math.PI * 2 - ang;\n }\n return ang;\n }\n\n if (angleLargeThanPI) {\n return ang;\n }\n return Math.PI * 2 - ang;\n}\n"]}
|
package/cjs/util/text.js
CHANGED
|
@@ -14,17 +14,17 @@ const vrender_1 = require("@visactor/vrender"), vutils_1 = require("@visactor/vu
|
|
|
14
14
|
}, null != option ? option : {}), textSpec);
|
|
15
15
|
|
|
16
16
|
function measureTextSize(text, textSpec) {
|
|
17
|
-
var _a
|
|
17
|
+
var _a;
|
|
18
18
|
if (!text) return {
|
|
19
19
|
width: 0,
|
|
20
20
|
height: 0
|
|
21
21
|
};
|
|
22
22
|
const bounds = (0, vrender_1.getTextBounds)({
|
|
23
23
|
text: text,
|
|
24
|
-
fontFamily:
|
|
24
|
+
fontFamily: textSpec.fontFamily,
|
|
25
25
|
fontSize: textSpec.fontSize || 12,
|
|
26
26
|
fontWeight: textSpec.fontWeight,
|
|
27
|
-
textAlign: null !== (
|
|
27
|
+
textAlign: null !== (_a = textSpec.textAlign) && void 0 !== _a ? _a : "center",
|
|
28
28
|
textBaseline: textSpec.textBaseline,
|
|
29
29
|
ellipsis: !!textSpec.ellipsis,
|
|
30
30
|
maxLineWidth: textSpec.maxLineWidth || 1 / 0,
|
package/cjs/util/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":";;;AAEA,+CAAkD;AAGlD,6CAA+C;AAC/C,0CAA+E;AAExE,MAAM,eAAe,GAAG,CAC7B,QAAyC,EACzC,MAAoC,EACpC,cAAwB,EACY,EAAE;IACtC,OAAO,IAAI,oBAAW,iBAElB,iBAAiB,EAAE;YACjB,UAAU,EAAE,mCAAwB;YACpC,QAAQ,EAAE,iCAAsB;SACjC,EACD,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAa,EACzD,cAAc,EAAE,cAAc,GAAG,oBAAW,CAAC,iBAAiB,GAAG,oBAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE,IACzG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAEnB,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B;AAGF,SAAgB,eAAe,CAAC,IAA2C,EAAE,QAAwC;;IACnH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KAChC;IACD,MAAM,MAAM,GAAG,IAAA,uBAAa,EAAC;QAC3B,IAAI;QACJ,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":";;;AAEA,+CAAkD;AAGlD,6CAA+C;AAC/C,0CAA+E;AAExE,MAAM,eAAe,GAAG,CAC7B,QAAyC,EACzC,MAAoC,EACpC,cAAwB,EACY,EAAE;IACtC,OAAO,IAAI,oBAAW,iBAElB,iBAAiB,EAAE;YACjB,UAAU,EAAE,mCAAwB;YACpC,QAAQ,EAAE,iCAAsB;SACjC,EACD,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAa,EACzD,cAAc,EAAE,cAAc,GAAG,oBAAW,CAAC,iBAAiB,GAAG,oBAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE,IACzG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAEnB,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B;AAGF,SAAgB,eAAe,CAAC,IAA2C,EAAE,QAAwC;;IACnH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KAChC;IACD,MAAM,MAAM,GAAG,IAAA,uBAAa,EAAC;QAC3B,IAAI;QACJ,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;QACjC,UAAU,EAAE,QAAQ,CAAC,UAAiB;QACtC,SAAS,EAAE,MAAA,QAAQ,CAAC,SAAS,mCAAI,QAAQ;QACzC,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ;QAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,QAAQ;QAC/C,UAAU,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;KACpC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;AAC5D,CAAC;AAjBD,0CAiBC","file":"text.js","sourcesContent":["import type { ITextGraphicAttribute } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTextBounds } from '@visactor/vrender';\nimport type { ITextMeasureOption } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { TextMeasure } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(text: string | number | string[] | number[], textSpec: Partial<ITextGraphicAttribute>) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily,\n fontSize: textSpec.fontSize || 12,\n fontWeight: textSpec.fontWeight as any,\n textAlign: textSpec.textAlign ?? 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n"]}
|