@visactor/vrender-components 0.20.10 → 0.20.11-alpha.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.
- package/cjs/axis/overlap/auto-wrap.js +19 -6
- package/cjs/axis/overlap/auto-wrap.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +36 -9
- package/es/axis/overlap/auto-wrap.js +19 -7
- package/es/axis/overlap/auto-wrap.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -9,16 +9,22 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("./util");
|
|
|
9
9
|
function autoWrap(labels, config) {
|
|
10
10
|
const {limitLength: limitLength, axisLength: axisLength, ellipsis: ellipsis = "...", orient: orient} = config;
|
|
11
11
|
if ((0, vutils_1.isEmpty)(labels) || !(0, vutils_1.isValidNumber)(limitLength)) return;
|
|
12
|
-
|
|
13
|
-
labels.forEach((label => {
|
|
14
|
-
var _a;
|
|
12
|
+
let verticalLimitLength = axisLength / labels.length;
|
|
13
|
+
labels.forEach(((label, index) => {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
15
|
const angle = label.attribute.angle, isHorizontal = (0, util_1.isAngleHorizontal)(angle), isVertical = (0,
|
|
16
16
|
util_1.isAngleVertical)(angle), isX = "top" === orient || "bottom" === orient;
|
|
17
17
|
if (isX) {
|
|
18
18
|
if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
|
|
19
|
-
if (isHorizontal
|
|
19
|
+
if (isHorizontal) {
|
|
20
|
+
const minGap = getLabelMinGap(label.attribute.x, null === (_a = labels[index + 1]) || void 0 === _a ? void 0 : _a.attribute.x, null === (_b = labels[index - 1]) || void 0 === _b ? void 0 : _b.attribute.x);
|
|
21
|
+
(0, vutils_1.isValidNumber)(minGap) && (verticalLimitLength = (0, vutils_1.min)(verticalLimitLength, minGap));
|
|
22
|
+
}
|
|
20
23
|
} else {
|
|
21
|
-
if (isVertical
|
|
24
|
+
if (isVertical) {
|
|
25
|
+
const minGap = getLabelMinGap(label.attribute.y, null === (_c = labels[index + 1]) || void 0 === _c ? void 0 : _c.attribute.y, null === (_d = labels[index - 1]) || void 0 === _d ? void 0 : _d.attribute.y);
|
|
26
|
+
(0, vutils_1.isValidNumber)(minGap) && (verticalLimitLength = (0, vutils_1.min)(verticalLimitLength, minGap));
|
|
27
|
+
}
|
|
22
28
|
if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) return;
|
|
23
29
|
}
|
|
24
30
|
let limitLabelLength = null, heightLimit = null;
|
|
@@ -27,12 +33,19 @@ function autoWrap(labels, config) {
|
|
|
27
33
|
heightLimit = limitLength) : (limitLabelLength = limitLength, heightLimit = verticalLimitLength),
|
|
28
34
|
label.setAttributes({
|
|
29
35
|
maxLineWidth: limitLabelLength,
|
|
30
|
-
ellipsis: null !== (
|
|
36
|
+
ellipsis: null !== (_e = label.attribute.ellipsis) && void 0 !== _e ? _e : ellipsis,
|
|
31
37
|
whiteSpace: "normal",
|
|
32
38
|
heightLimit: heightLimit
|
|
33
39
|
});
|
|
34
40
|
}));
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
function getLabelMinGap(current, next, prev) {
|
|
44
|
+
let minGap;
|
|
45
|
+
return (0, vutils_1.isValidNumber)(next) && (minGap = Math.abs(next - current)),
|
|
46
|
+
(0, vutils_1.isValidNumber)(prev) && (minGap = (0, vutils_1.isValidNumber)(minGap) ? Math.min(Math.abs(current - prev), minGap) : Math.abs(current - prev)),
|
|
47
|
+
minGap;
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
exports.autoWrap = autoWrap;
|
|
38
51
|
//# sourceMappingURL=auto-wrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/overlap/auto-wrap.ts"],"names":[],"mappings":";;;AAC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GAAG,mBAAmB,CAAC;aACnC;SACF;QACD,KAAK,CAAC,aAAa,CAAC;YAClB,YAAY,EAAE,gBAAgB;YAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,SAAS,CAAC,QAAQ,mCAAI,QAAQ;YAC9C,UAAU,EAAE,QAAQ;YACpB,WAAW;SACZ,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAtED,4BAsEC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,IAAa,EAAE,IAAa;IACnE,IAAI,MAAM,CAAC;IACX,IAAI,IAAA,sBAAa,EAAC,IAAI,CAAC,EAAE;QACvB,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;KACnC;IAED,IAAI,IAAA,sBAAa,EAAC,IAAI,CAAC,EAAE;QACvB,IAAI,IAAA,sBAAa,EAAC,MAAM,CAAC,EAAE;YACzB,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;SACrD;aAAM;YACL,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;SACnC;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","file":"auto-wrap.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isValidNumber, min } from '@visactor/vutils';\nimport { isAngleHorizontal, isAngleVertical } from './util';\n\ntype WrapConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n ellipsis?: string;\n};\n\nexport function autoWrap(labels: IText[], config: WrapConfig) {\n const { limitLength, axisLength, ellipsis = '...', orient } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n let verticalLimitLength = axisLength / labels.length;\n\n labels.forEach((label, index) => {\n const angle = label.attribute.angle;\n\n const isHorizontal = isAngleHorizontal(angle);\n const isVertical = isAngleVertical(angle);\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal) {\n const curLabelX = label.attribute.x;\n const nextLabelX = labels[index + 1]?.attribute.x;\n const lastLabelX = labels[index - 1]?.attribute.x;\n const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX);\n if (isValidNumber(minGap)) {\n verticalLimitLength = min(verticalLimitLength, minGap);\n }\n }\n } else {\n if (isVertical) {\n const curLabelY = label.attribute.y;\n const nextLabelY = labels[index + 1]?.attribute.y;\n const lastLabelY = labels[index - 1]?.attribute.y;\n const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY);\n if (isValidNumber(minGap)) {\n verticalLimitLength = min(verticalLimitLength, minGap);\n }\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n }\n\n let limitLabelLength = null;\n let heightLimit = null;\n\n if (isX) {\n if (isVertical) {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n } else {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n }\n } else {\n if (isVertical) {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n } else {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n }\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis,\n whiteSpace: 'normal',\n heightLimit\n });\n });\n}\n\nfunction getLabelMinGap(current: number, next?: number, prev?: number) {\n let minGap;\n if (isValidNumber(next)) {\n minGap = Math.abs(next - current);\n }\n\n if (isValidNumber(prev)) {\n if (isValidNumber(minGap)) {\n minGap = Math.min(Math.abs(current - prev), minGap);\n } else {\n minGap = Math.abs(current - prev);\n }\n }\n\n return minGap;\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
|
-
}), exports.version = void 0, exports.version = "0.20.
|
|
20
|
+
}), exports.version = void 0, exports.version = "0.20.11-alpha.0", __exportStar(require("./core/base"), exports),
|
|
21
21
|
__exportStar(require("./core/type"), exports), __exportStar(require("./scrollbar"), exports),
|
|
22
22
|
__exportStar(require("./tag"), exports), __exportStar(require("./poptip"), exports),
|
|
23
23
|
__exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.11-alpha.0\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -19378,9 +19378,9 @@ function autoWrap(labels, config) {
|
|
|
19378
19378
|
if (isEmpty(labels) || !isValidNumber(limitLength)) {
|
|
19379
19379
|
return;
|
|
19380
19380
|
}
|
|
19381
|
-
|
|
19382
|
-
labels.forEach(label => {
|
|
19383
|
-
var _a;
|
|
19381
|
+
let verticalLimitLength = axisLength / labels.length;
|
|
19382
|
+
labels.forEach((label, index) => {
|
|
19383
|
+
var _a, _b, _c, _d, _e;
|
|
19384
19384
|
const angle = label.attribute.angle;
|
|
19385
19385
|
const isHorizontal = isAngleHorizontal(angle);
|
|
19386
19386
|
const isVertical = isAngleVertical(angle);
|
|
@@ -19389,13 +19389,25 @@ function autoWrap(labels, config) {
|
|
|
19389
19389
|
if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {
|
|
19390
19390
|
return;
|
|
19391
19391
|
}
|
|
19392
|
-
if (isHorizontal
|
|
19393
|
-
|
|
19392
|
+
if (isHorizontal) {
|
|
19393
|
+
const curLabelX = label.attribute.x;
|
|
19394
|
+
const nextLabelX = (_a = labels[index + 1]) === null || _a === void 0 ? void 0 : _a.attribute.x;
|
|
19395
|
+
const lastLabelX = (_b = labels[index - 1]) === null || _b === void 0 ? void 0 : _b.attribute.x;
|
|
19396
|
+
const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX);
|
|
19397
|
+
if (isValidNumber(minGap)) {
|
|
19398
|
+
verticalLimitLength = min(verticalLimitLength, minGap);
|
|
19399
|
+
}
|
|
19394
19400
|
}
|
|
19395
19401
|
}
|
|
19396
19402
|
else {
|
|
19397
|
-
if (isVertical
|
|
19398
|
-
|
|
19403
|
+
if (isVertical) {
|
|
19404
|
+
const curLabelY = label.attribute.y;
|
|
19405
|
+
const nextLabelY = (_c = labels[index + 1]) === null || _c === void 0 ? void 0 : _c.attribute.y;
|
|
19406
|
+
const lastLabelY = (_d = labels[index - 1]) === null || _d === void 0 ? void 0 : _d.attribute.y;
|
|
19407
|
+
const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY);
|
|
19408
|
+
if (isValidNumber(minGap)) {
|
|
19409
|
+
verticalLimitLength = min(verticalLimitLength, minGap);
|
|
19410
|
+
}
|
|
19399
19411
|
}
|
|
19400
19412
|
if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {
|
|
19401
19413
|
return;
|
|
@@ -19425,12 +19437,27 @@ function autoWrap(labels, config) {
|
|
|
19425
19437
|
}
|
|
19426
19438
|
label.setAttributes({
|
|
19427
19439
|
maxLineWidth: limitLabelLength,
|
|
19428
|
-
ellipsis: (
|
|
19440
|
+
ellipsis: (_e = label.attribute.ellipsis) !== null && _e !== void 0 ? _e : ellipsis,
|
|
19429
19441
|
whiteSpace: 'normal',
|
|
19430
19442
|
heightLimit
|
|
19431
19443
|
});
|
|
19432
19444
|
});
|
|
19433
19445
|
}
|
|
19446
|
+
function getLabelMinGap(current, next, prev) {
|
|
19447
|
+
let minGap;
|
|
19448
|
+
if (isValidNumber(next)) {
|
|
19449
|
+
minGap = Math.abs(next - current);
|
|
19450
|
+
}
|
|
19451
|
+
if (isValidNumber(prev)) {
|
|
19452
|
+
if (isValidNumber(minGap)) {
|
|
19453
|
+
minGap = Math.min(Math.abs(current - prev), minGap);
|
|
19454
|
+
}
|
|
19455
|
+
else {
|
|
19456
|
+
minGap = Math.abs(current - prev);
|
|
19457
|
+
}
|
|
19458
|
+
}
|
|
19459
|
+
return minGap;
|
|
19460
|
+
}
|
|
19434
19461
|
|
|
19435
19462
|
function alignAxisLabels(labels, start, containerSize, orient, align) {
|
|
19436
19463
|
if (orient === 'left' || orient === 'right') {
|
|
@@ -29355,6 +29382,6 @@ EmptyTip.defaultAttributes = {
|
|
|
29355
29382
|
}
|
|
29356
29383
|
};
|
|
29357
29384
|
|
|
29358
|
-
const version = "0.20.
|
|
29385
|
+
const version = "0.20.11-alpha.0";
|
|
29359
29386
|
|
|
29360
29387
|
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { isEmpty, isValidNumber } from "@visactor/vutils";
|
|
1
|
+
import { isEmpty, isValidNumber, min } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { isAngleHorizontal, isAngleVertical } from "./util";
|
|
4
4
|
|
|
5
5
|
export function autoWrap(labels, config) {
|
|
6
6
|
const {limitLength: limitLength, axisLength: axisLength, ellipsis: ellipsis = "...", orient: orient} = config;
|
|
7
7
|
if (isEmpty(labels) || !isValidNumber(limitLength)) return;
|
|
8
|
-
|
|
9
|
-
labels.forEach((label => {
|
|
10
|
-
var _a;
|
|
8
|
+
let verticalLimitLength = axisLength / labels.length;
|
|
9
|
+
labels.forEach(((label, index) => {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
11
|
const angle = label.attribute.angle, isHorizontal = isAngleHorizontal(angle), isVertical = isAngleVertical(angle), isX = "top" === orient || "bottom" === orient;
|
|
12
12
|
if (isX) {
|
|
13
13
|
if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
|
|
14
|
-
if (isHorizontal
|
|
14
|
+
if (isHorizontal) {
|
|
15
|
+
const minGap = getLabelMinGap(label.attribute.x, null === (_a = labels[index + 1]) || void 0 === _a ? void 0 : _a.attribute.x, null === (_b = labels[index - 1]) || void 0 === _b ? void 0 : _b.attribute.x);
|
|
16
|
+
isValidNumber(minGap) && (verticalLimitLength = min(verticalLimitLength, minGap));
|
|
17
|
+
}
|
|
15
18
|
} else {
|
|
16
|
-
if (isVertical
|
|
19
|
+
if (isVertical) {
|
|
20
|
+
const minGap = getLabelMinGap(label.attribute.y, null === (_c = labels[index + 1]) || void 0 === _c ? void 0 : _c.attribute.y, null === (_d = labels[index - 1]) || void 0 === _d ? void 0 : _d.attribute.y);
|
|
21
|
+
isValidNumber(minGap) && (verticalLimitLength = min(verticalLimitLength, minGap));
|
|
22
|
+
}
|
|
17
23
|
if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) return;
|
|
18
24
|
}
|
|
19
25
|
let limitLabelLength = null, heightLimit = null;
|
|
@@ -22,10 +28,16 @@ export function autoWrap(labels, config) {
|
|
|
22
28
|
heightLimit = limitLength) : (limitLabelLength = limitLength, heightLimit = verticalLimitLength),
|
|
23
29
|
label.setAttributes({
|
|
24
30
|
maxLineWidth: limitLabelLength,
|
|
25
|
-
ellipsis: null !== (
|
|
31
|
+
ellipsis: null !== (_e = label.attribute.ellipsis) && void 0 !== _e ? _e : ellipsis,
|
|
26
32
|
whiteSpace: "normal",
|
|
27
33
|
heightLimit: heightLimit
|
|
28
34
|
});
|
|
29
35
|
}));
|
|
30
36
|
}
|
|
37
|
+
|
|
38
|
+
function getLabelMinGap(current, next, prev) {
|
|
39
|
+
let minGap;
|
|
40
|
+
return isValidNumber(next) && (minGap = Math.abs(next - current)), isValidNumber(prev) && (minGap = isValidNumber(minGap) ? Math.min(Math.abs(current - prev), minGap) : Math.abs(current - prev)),
|
|
41
|
+
minGap;
|
|
42
|
+
}
|
|
31
43
|
//# sourceMappingURL=auto-wrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/overlap/auto-wrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+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L,gBAAgB,GAAG,WAAW,CAAC;gBAC/B,WAAW,GAAG,mBAAmB,CAAC;aACnC;SACF;QACD,KAAK,CAAC,aAAa,CAAC;YAClB,YAAY,EAAE,gBAAgB;YAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,SAAS,CAAC,QAAQ,mCAAI,QAAQ;YAC9C,UAAU,EAAE,QAAQ;YACpB,WAAW;SACZ,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,IAAa,EAAE,IAAa;IACnE,IAAI,MAAM,CAAC;IACX,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;QACvB,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;KACnC;IAED,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;QACvB,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;SACrD;aAAM;YACL,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;SACnC;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","file":"auto-wrap.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isValidNumber, min } from '@visactor/vutils';\nimport { isAngleHorizontal, isAngleVertical } from './util';\n\ntype WrapConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n ellipsis?: string;\n};\n\nexport function autoWrap(labels: IText[], config: WrapConfig) {\n const { limitLength, axisLength, ellipsis = '...', orient } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n let verticalLimitLength = axisLength / labels.length;\n\n labels.forEach((label, index) => {\n const angle = label.attribute.angle;\n\n const isHorizontal = isAngleHorizontal(angle);\n const isVertical = isAngleVertical(angle);\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal) {\n const curLabelX = label.attribute.x;\n const nextLabelX = labels[index + 1]?.attribute.x;\n const lastLabelX = labels[index - 1]?.attribute.x;\n const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX);\n if (isValidNumber(minGap)) {\n verticalLimitLength = min(verticalLimitLength, minGap);\n }\n }\n } else {\n if (isVertical) {\n const curLabelY = label.attribute.y;\n const nextLabelY = labels[index + 1]?.attribute.y;\n const lastLabelY = labels[index - 1]?.attribute.y;\n const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY);\n if (isValidNumber(minGap)) {\n verticalLimitLength = min(verticalLimitLength, minGap);\n }\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n }\n\n let limitLabelLength = null;\n let heightLimit = null;\n\n if (isX) {\n if (isVertical) {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n } else {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n }\n } else {\n if (isVertical) {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n } else {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n }\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis,\n whiteSpace: 'normal',\n heightLimit\n });\n });\n}\n\nfunction getLabelMinGap(current: number, next?: number, prev?: number) {\n let minGap;\n if (isValidNumber(next)) {\n minGap = Math.abs(next - current);\n }\n\n if (isValidNumber(prev)) {\n if (isValidNumber(minGap)) {\n minGap = Math.min(Math.abs(current - prev), minGap);\n } else {\n minGap = Math.abs(current - prev);\n }\n }\n\n return minGap;\n}\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.11-alpha.0\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-components",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.11-alpha.0",
|
|
4
4
|
"description": "components library for dp visualization",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@visactor/vutils": "~0.18.17",
|
|
16
16
|
"@visactor/vscale": "~0.18.17",
|
|
17
|
-
"@visactor/vrender-core": "0.20.
|
|
18
|
-
"@visactor/vrender-kits": "0.20.
|
|
17
|
+
"@visactor/vrender-core": "0.20.11-alpha.0",
|
|
18
|
+
"@visactor/vrender-kits": "0.20.11-alpha.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@rushstack/eslint-patch": "~1.1.4",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"typescript": "4.9.5",
|
|
31
31
|
"cross-env": "^7.0.3",
|
|
32
32
|
"@internal/bundler": "0.0.1",
|
|
33
|
-
"@internal/
|
|
34
|
-
"@internal/
|
|
33
|
+
"@internal/ts-config": "0.0.1",
|
|
34
|
+
"@internal/eslint-config": "0.0.1"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"VisActor",
|