@antv/component 2.1.3 → 2.1.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/dist/component.min.js +1 -1
- package/esm/animation/fadeIn.d.ts +1 -1
- package/esm/animation/fadeOut.d.ts +1 -1
- package/esm/animation/utils.d.ts +3 -3
- package/esm/ui/axis/axis.d.ts +1 -1
- package/esm/ui/axis/axis.js +1 -1
- package/esm/ui/axis/axis.js.map +1 -1
- package/esm/ui/axis/guides/grid.d.ts +1 -1
- package/esm/ui/axis/guides/labels.d.ts +2 -1
- package/esm/ui/axis/guides/labels.js +4 -4
- package/esm/ui/axis/guides/labels.js.map +1 -1
- package/esm/ui/axis/guides/ticks.d.ts +1 -1
- package/esm/ui/axis/guides/title.d.ts +1 -1
- package/esm/ui/axis/overlap/autoEllipsis.js +1 -1
- package/esm/ui/axis/overlap/autoWrap.d.ts +2 -2
- package/esm/ui/axis/overlap/autoWrap.js +5 -2
- package/esm/ui/axis/overlap/autoWrap.js.map +1 -1
- package/esm/ui/axis/overlap/index.d.ts +1 -1
- package/esm/ui/axis/overlap/index.js +3 -3
- package/esm/ui/axis/overlap/index.js.map +1 -1
- package/esm/ui/axis/types.d.ts +1 -1
- package/esm/ui/grid/index.d.ts +1 -1
- package/esm/util/keyframe-interpolate.d.ts +1 -1
- package/lib/animation/fadeIn.d.ts +1 -1
- package/lib/animation/fadeOut.d.ts +1 -1
- package/lib/animation/utils.d.ts +3 -3
- package/lib/ui/axis/axis.d.ts +1 -1
- package/lib/ui/axis/axis.js +1 -1
- package/lib/ui/axis/axis.js.map +1 -1
- package/lib/ui/axis/guides/grid.d.ts +1 -1
- package/lib/ui/axis/guides/labels.d.ts +2 -1
- package/lib/ui/axis/guides/labels.js +4 -4
- package/lib/ui/axis/guides/labels.js.map +1 -1
- package/lib/ui/axis/guides/ticks.d.ts +1 -1
- package/lib/ui/axis/guides/title.d.ts +1 -1
- package/lib/ui/axis/overlap/autoEllipsis.js +1 -1
- package/lib/ui/axis/overlap/autoWrap.d.ts +2 -2
- package/lib/ui/axis/overlap/autoWrap.js +5 -2
- package/lib/ui/axis/overlap/autoWrap.js.map +1 -1
- package/lib/ui/axis/overlap/index.d.ts +1 -1
- package/lib/ui/axis/overlap/index.js +3 -3
- package/lib/ui/axis/overlap/index.js.map +1 -1
- package/lib/ui/axis/types.d.ts +1 -1
- package/lib/ui/grid/index.d.ts +1 -1
- package/lib/util/keyframe-interpolate.d.ts +1 -1
- package/package.json +1 -1
- package/src/ui/axis/axis.ts +1 -1
- package/src/ui/axis/guides/labels.ts +5 -4
- package/src/ui/axis/overlap/autoEllipsis.ts +1 -1
- package/src/ui/axis/overlap/autoWrap.ts +11 -4
- package/src/ui/axis/overlap/index.ts +8 -3
- package/src/ui/axis/types.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/axis/overlap/index.ts"],"names":[],"mappings":";;;AAwBA,8CAUC;AAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/axis/overlap/index.ts"],"names":[],"mappings":";;;AAwBA,8CAUC;AAED,wCAaC;;AA/CD,sCAAmD;AAGnD,wEAAsC;AAEtC,gEAA8B;AAE9B,oEAAkC;AAElC,gEAA8B;AAMjB,QAAA,YAAY,GAAG,IAAI,GAAG,CAAc;IAC/C,CAAC,MAAM,EAAE,kBAAI,CAAC;IACd,CAAC,QAAQ,EAAE,oBAAM,CAAC;IAClB,CAAC,UAAU,EAAE,sBAAQ,CAAC;IACtB,CAAC,MAAM,EAAE,kBAAI,CAAC;CACf,CAAC,CAAC;AAEH,SAAgB,iBAAiB,CAC/B,MAAuB,EACvB,IAA8B,EAC9B,IAA6B;IAE7B,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,CAAC,IAAA,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wordWrapWidth?: number
|
|
41
|
+
wordWrapWidth?: Callable<number, [DisplayObject]>;
|
|
42
42
|
maxLines?: number;
|
|
43
43
|
recoverWhenFailed?: boolean;
|
|
44
44
|
}
|
package/lib/ui/grid/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import type { Group } from '../../shapes';
|
|
|
3
3
|
import type { GridOptions, GridStyleProps } from './types';
|
|
4
4
|
export type { GridOptions, GridStyleProps };
|
|
5
5
|
export declare class Grid extends Component<GridStyleProps> {
|
|
6
|
-
render(attributes: GridStyleProps, container: Group): import("
|
|
6
|
+
render(attributes: GridStyleProps, container: Group): import("@antv/g").IAnimation[];
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { GenericAnimation } from '../animation';
|
|
2
2
|
import type { DisplayObject } from '../shapes';
|
|
3
3
|
import type { Interpolatable } from './interpolate';
|
|
4
|
-
export declare function keyframeInterpolate<T extends Interpolatable>(element: DisplayObject, from: T, to: T, options: GenericAnimation): import("
|
|
4
|
+
export declare function keyframeInterpolate<T extends Interpolatable>(element: DisplayObject, from: T, to: T, options: GenericAnimation): import("@antv/g").IAnimation | null;
|
package/package.json
CHANGED
package/src/ui/axis/axis.ts
CHANGED
|
@@ -46,7 +46,7 @@ function renderAxisMain(
|
|
|
46
46
|
const labelGroup = container.maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g');
|
|
47
47
|
const labelTransitions =
|
|
48
48
|
ifShow(showLabel!, labelGroup, (group) => {
|
|
49
|
-
return renderLabels(group, data, attributes, animation);
|
|
49
|
+
return renderLabels(group, data, attributes, animation, container.node());
|
|
50
50
|
}) || [];
|
|
51
51
|
|
|
52
52
|
return [...lineTransitions, ...tickTransitions, ...labelTransitions].filter((t) => !!t);
|
|
@@ -170,8 +170,8 @@ function applyTextStyle(node: DisplayObject, style: Partial<TextStyleProps>) {
|
|
|
170
170
|
if (node.nodeName === 'text') node.attr(style);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
function overlapHandler(attr: Required<AxisStyleProps
|
|
174
|
-
processOverlap(this.node().childNodes as DisplayObject[], attr, {
|
|
173
|
+
function overlapHandler(attr: Required<AxisStyleProps>, main: DisplayObject) {
|
|
174
|
+
processOverlap(this.node().childNodes as DisplayObject[], attr, main, {
|
|
175
175
|
hide,
|
|
176
176
|
show,
|
|
177
177
|
rotate: (label, angle) => {
|
|
@@ -219,7 +219,8 @@ export function renderLabels(
|
|
|
219
219
|
container: Selection,
|
|
220
220
|
data: AxisDatum[],
|
|
221
221
|
attr: Required<AxisStyleProps>,
|
|
222
|
-
animate: StandardAnimationOption
|
|
222
|
+
animate: StandardAnimationOption,
|
|
223
|
+
main: DisplayObject
|
|
223
224
|
) {
|
|
224
225
|
const finalData = filterExec(data, attr.labelFilter);
|
|
225
226
|
const style = subStyleProps<AxisLabelStyleProps>(attr, 'label');
|
|
@@ -262,7 +263,7 @@ export function renderLabels(
|
|
|
262
263
|
.transitions();
|
|
263
264
|
// handle overlapping after transitions finished
|
|
264
265
|
onAnimatesFinished(transitions, () => {
|
|
265
|
-
overlapHandler.call(container, attr);
|
|
266
|
+
overlapHandler.call(container, attr, main);
|
|
266
267
|
});
|
|
267
268
|
return transitions;
|
|
268
269
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getCallbackValue } from '../../../util';
|
|
2
|
+
import type { DisplayObject, Text } from '../../../shapes';
|
|
2
3
|
import { isAxisHorizontal } from '../guides/line';
|
|
3
4
|
import { AxisStyleProps, LinearAxisStyleProps, WrapOverlapCfg } from '../types';
|
|
4
5
|
import { boundTest } from '../utils/test';
|
|
@@ -17,9 +18,15 @@ function inferTextBaseline(attr: AxisStyleProps) {
|
|
|
17
18
|
return 'middle';
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export default function wrapLabels(
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
export default function wrapLabels(
|
|
22
|
+
labels: Text[],
|
|
23
|
+
overlapCfg: WrapOverlapCfg,
|
|
24
|
+
attr: AxisStyleProps,
|
|
25
|
+
utils: Utils,
|
|
26
|
+
main: DisplayObject
|
|
27
|
+
) {
|
|
28
|
+
const { maxLines = 3, recoverWhenFailed = true, margin = [0, 0, 0, 0] } = overlapCfg;
|
|
29
|
+
const wordWrapWidth = getCallbackValue(overlapCfg.wordWrapWidth ?? 50, [main]);
|
|
23
30
|
const defaultLines = labels.map((label) => label.attr('maxLines') || 1);
|
|
24
31
|
|
|
25
32
|
const minLines = Math.min(...defaultLines);
|
|
@@ -30,16 +30,21 @@ export function canProcessOverlap(
|
|
|
30
30
|
if (attr.labelOverlap.length < 1) return false;
|
|
31
31
|
if (type === 'hide') return !isInOffscreenGroup(labels[0]);
|
|
32
32
|
if (type === 'rotate') return !labels.some((label) => !!label.attr('transform')?.includes('rotate'));
|
|
33
|
-
if (type === 'ellipsis' || type === 'wrap') return labels.filter((item) => item.querySelector('text')).length
|
|
33
|
+
if (type === 'ellipsis' || type === 'wrap') return labels.filter((item) => item.querySelector('text')).length >= 1;
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function processOverlap(
|
|
37
|
+
export function processOverlap(
|
|
38
|
+
labels: DisplayObject[],
|
|
39
|
+
attr: Required<AxisStyleProps>,
|
|
40
|
+
main: DisplayObject,
|
|
41
|
+
utils: OverlapUtilsType
|
|
42
|
+
) {
|
|
38
43
|
const { labelOverlap = [] } = attr;
|
|
39
44
|
if (!labelOverlap.length) return;
|
|
40
45
|
labelOverlap.forEach((overlapCfg) => {
|
|
41
46
|
const { type } = overlapCfg;
|
|
42
47
|
const util = OverlapUtils.get(type);
|
|
43
|
-
if (canProcessOverlap(labels, attr, type)) util?.(labels as any[], overlapCfg, attr, utils);
|
|
48
|
+
if (canProcessOverlap(labels, attr, type)) util?.(labels as any[], overlapCfg, attr, utils, main);
|
|
44
49
|
});
|
|
45
50
|
}
|
package/src/ui/axis/types.ts
CHANGED
|
@@ -44,7 +44,7 @@ export interface HideOverlapCfg extends Overlap {
|
|
|
44
44
|
}
|
|
45
45
|
export interface WrapOverlapCfg extends Overlap {
|
|
46
46
|
type: 'wrap';
|
|
47
|
-
wordWrapWidth?: number
|
|
47
|
+
wordWrapWidth?: Callable<number, [DisplayObject]>;
|
|
48
48
|
maxLines?: number;
|
|
49
49
|
recoverWhenFailed?: boolean;
|
|
50
50
|
}
|