@antv/component 2.0.0 → 2.0.2
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/core/component.d.ts +1 -0
- package/esm/core/component.js +5 -1
- package/esm/core/component.js.map +1 -1
- package/esm/ui/axis/axis.d.ts +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/ticks.d.ts +1 -1
- package/esm/ui/axis/guides/title.d.ts +1 -1
- package/esm/ui/checkbox/constant.d.ts +4 -3
- package/esm/ui/grid/index.d.ts +1 -1
- package/esm/ui/legend/base.d.ts +1 -1
- package/esm/ui/legend/category/item.js +14 -5
- package/esm/ui/legend/category/item.js.map +1 -1
- package/esm/ui/legend/continuous/utils.js.map +1 -1
- package/esm/ui/legend/continuous.d.ts +2 -1
- package/esm/ui/legend/continuous.js +30 -8
- package/esm/ui/legend/continuous.js.map +1 -1
- package/esm/ui/marker/index.js +2 -1
- package/esm/ui/marker/index.js.map +1 -1
- package/esm/ui/tag/index.js +0 -4
- package/esm/ui/tag/index.js.map +1 -1
- package/esm/ui/timebar/controller.js.map +1 -1
- package/esm/ui/timebar/icons.d.ts +2 -2
- package/esm/ui/title/index.js.map +1 -1
- package/esm/ui/tooltip/index.js +6 -1
- package/esm/ui/tooltip/index.js.map +1 -1
- package/esm/util/group-by.js.map +1 -1
- package/esm/util/keyframe-interpolate.d.ts +1 -1
- package/esm/util/number.d.ts +2 -2
- package/esm/util/selection.d.ts +1 -2
- package/esm/util/text.d.ts +1 -1
- package/lib/animation/fadeIn.d.ts +1 -1
- package/lib/animation/fadeIn.js +1 -1
- package/lib/animation/fadeIn.js.map +1 -1
- package/lib/animation/fadeOut.d.ts +1 -1
- package/lib/animation/fadeOut.js +1 -1
- package/lib/animation/fadeOut.js.map +1 -1
- package/lib/animation/utils.d.ts +3 -3
- package/lib/animation/utils.js +6 -7
- package/lib/animation/utils.js.map +1 -1
- package/lib/core/component.d.ts +1 -0
- package/lib/core/component.js +4 -0
- package/lib/core/component.js.map +1 -1
- package/lib/ui/axis/axis.d.ts +1 -1
- package/lib/ui/axis/guides/grid.d.ts +1 -1
- package/lib/ui/axis/guides/grid.js +1 -2
- package/lib/ui/axis/guides/grid.js.map +1 -1
- package/lib/ui/axis/guides/labels.d.ts +2 -1
- package/lib/ui/axis/guides/labels.js +1 -2
- package/lib/ui/axis/guides/labels.js.map +1 -1
- package/lib/ui/axis/guides/line.js +6 -7
- package/lib/ui/axis/guides/line.js.map +1 -1
- package/lib/ui/axis/guides/ticks.d.ts +1 -1
- package/lib/ui/axis/guides/ticks.js +3 -4
- package/lib/ui/axis/guides/ticks.js.map +1 -1
- package/lib/ui/axis/guides/title.d.ts +1 -1
- package/lib/ui/axis/guides/title.js +1 -2
- package/lib/ui/axis/guides/title.js.map +1 -1
- package/lib/ui/axis/guides/utils.js +7 -8
- package/lib/ui/axis/guides/utils.js.map +1 -1
- package/lib/ui/axis/overlap/autoEllipsis.js +1 -1
- package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
- package/lib/ui/axis/overlap/autoHide.js +1 -1
- package/lib/ui/axis/overlap/autoHide.js.map +1 -1
- package/lib/ui/axis/overlap/autoRotate.js +1 -1
- package/lib/ui/axis/overlap/autoRotate.js.map +1 -1
- package/lib/ui/axis/overlap/autoWrap.js +1 -1
- package/lib/ui/axis/overlap/autoWrap.js.map +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/utils/bounds.js +2 -2
- package/lib/ui/axis/utils/bounds.js.map +1 -1
- package/lib/ui/axis/utils/contain.js +3 -4
- package/lib/ui/axis/utils/contain.js.map +1 -1
- package/lib/ui/axis/utils/index.js +1 -2
- package/lib/ui/axis/utils/index.js.map +1 -1
- package/lib/ui/axis/utils/intersect.js +2 -2
- package/lib/ui/axis/utils/intersect.js.map +1 -1
- package/lib/ui/axis/utils/test.js +1 -2
- package/lib/ui/axis/utils/test.js.map +1 -1
- package/lib/ui/checkbox/constant.d.ts +4 -3
- package/lib/ui/grid/index.d.ts +1 -1
- package/lib/ui/legend/base.d.ts +1 -1
- package/lib/ui/legend/base.js +4 -5
- package/lib/ui/legend/base.js.map +1 -1
- package/lib/ui/legend/category/item.js +14 -5
- package/lib/ui/legend/category/item.js.map +1 -1
- package/lib/ui/legend/continuous/utils.js +2 -3
- package/lib/ui/legend/continuous/utils.js.map +1 -1
- package/lib/ui/legend/continuous.d.ts +2 -1
- package/lib/ui/legend/continuous.js +30 -8
- package/lib/ui/legend/continuous.js.map +1 -1
- package/lib/ui/legend/utils.js +7 -7
- package/lib/ui/legend/utils.js.map +1 -1
- package/lib/ui/marker/index.js +2 -1
- package/lib/ui/marker/index.js.map +1 -1
- package/lib/ui/marker/symbol.js +2 -2
- package/lib/ui/marker/symbol.js.map +1 -1
- package/lib/ui/marker/utils.js +1 -2
- package/lib/ui/marker/utils.js.map +1 -1
- package/lib/ui/poptip/utils.js +2 -3
- package/lib/ui/poptip/utils.js.map +1 -1
- package/lib/ui/sparkline/path.js +7 -8
- package/lib/ui/sparkline/path.js.map +1 -1
- package/lib/ui/sparkline/utils.js +2 -3
- package/lib/ui/sparkline/utils.js.map +1 -1
- package/lib/ui/tag/index.js +0 -4
- package/lib/ui/tag/index.js.map +1 -1
- package/lib/ui/timebar/controller.js.map +1 -1
- package/lib/ui/timebar/icons.d.ts +2 -2
- package/lib/ui/timebar/utils.js +3 -4
- package/lib/ui/timebar/utils.js.map +1 -1
- package/lib/ui/title/index.js +3 -3
- package/lib/ui/title/index.js.map +1 -1
- package/lib/ui/tooltip/constant.js +2 -3
- package/lib/ui/tooltip/constant.js.map +1 -1
- package/lib/ui/tooltip/index.js +6 -1
- package/lib/ui/tooltip/index.js.map +1 -1
- package/lib/util/angle-converter.js +2 -3
- package/lib/util/angle-converter.js.map +1 -1
- package/lib/util/bbox.js +2 -2
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/callback.js +1 -2
- package/lib/util/callback.js.map +1 -1
- package/lib/util/ellipsis.js +1 -2
- package/lib/util/ellipsis.js.map +1 -1
- package/lib/util/event.js +1 -2
- package/lib/util/event.js.map +1 -1
- package/lib/util/extend-display-object.js +1 -2
- package/lib/util/extend-display-object.js.map +1 -1
- package/lib/util/geometry/line-length.js +1 -2
- package/lib/util/geometry/line-length.js.map +1 -1
- package/lib/util/geometry/lines-intersection.js +1 -2
- package/lib/util/geometry/lines-intersection.js.map +1 -1
- package/lib/util/group-by.js +1 -2
- package/lib/util/group-by.js.map +1 -1
- package/lib/util/group.js +1 -2
- package/lib/util/group.js.map +1 -1
- package/lib/util/html.js +2 -3
- package/lib/util/html.js.map +1 -1
- package/lib/util/if-show.js +1 -2
- package/lib/util/if-show.js.map +1 -1
- package/lib/util/in-range.js +1 -2
- package/lib/util/in-range.js.map +1 -1
- package/lib/util/interpolate.js +4 -4
- package/lib/util/interpolate.js.map +1 -1
- package/lib/util/keyframe-interpolate.d.ts +1 -1
- package/lib/util/keyframe-interpolate.js +1 -2
- package/lib/util/keyframe-interpolate.js.map +1 -1
- package/lib/util/layout/utils/helper.js +1 -2
- package/lib/util/layout/utils/helper.js.map +1 -1
- package/lib/util/matrix.js +9 -10
- package/lib/util/matrix.js.map +1 -1
- package/lib/util/number.d.ts +2 -2
- package/lib/util/number.js +5 -5
- package/lib/util/number.js.map +1 -1
- package/lib/util/offscreen.js +2 -3
- package/lib/util/offscreen.js.map +1 -1
- package/lib/util/omit.js +1 -2
- package/lib/util/omit.js.map +1 -1
- package/lib/util/path.js +1 -2
- package/lib/util/path.js.map +1 -1
- package/lib/util/primitive.js +3 -3
- package/lib/util/primitive.js.map +1 -1
- package/lib/util/sampling.js +1 -2
- package/lib/util/sampling.js.map +1 -1
- package/lib/util/scale-to-pixel.js +1 -2
- package/lib/util/scale-to-pixel.js.map +1 -1
- package/lib/util/selection.d.ts +1 -2
- package/lib/util/selection.js +3 -3
- package/lib/util/selection.js.map +1 -1
- package/lib/util/series.js +1 -2
- package/lib/util/series.js.map +1 -1
- package/lib/util/shape.js +6 -7
- package/lib/util/shape.js.map +1 -1
- package/lib/util/string.js +4 -5
- package/lib/util/string.js.map +1 -1
- package/lib/util/style.js +4 -5
- package/lib/util/style.js.map +1 -1
- package/lib/util/svg2marker.js +2 -3
- package/lib/util/svg2marker.js.map +1 -1
- package/lib/util/text.d.ts +1 -1
- package/lib/util/text.js +4 -4
- package/lib/util/text.js.map +1 -1
- package/lib/util/throttle.js +1 -2
- package/lib/util/throttle.js.map +1 -1
- package/lib/util/time.js +6 -7
- package/lib/util/time.js.map +1 -1
- package/lib/util/timer.js +1 -2
- package/lib/util/timer.js.map +1 -1
- package/lib/util/transform.js +2 -3
- package/lib/util/transform.js.map +1 -1
- package/lib/util/transpose.js +1 -2
- package/lib/util/transpose.js.map +1 -1
- package/lib/util/traverse.js +1 -2
- package/lib/util/traverse.js.map +1 -1
- package/lib/util/visibility.js +3 -4
- package/lib/util/visibility.js.map +1 -1
- package/lib/util/wrap.js +1 -2
- package/lib/util/wrap.js.map +1 -1
- package/package.json +9 -8
- package/src/core/component.ts +5 -0
- package/src/core/types.ts +2 -2
- package/src/ui/legend/category/item.ts +12 -5
- package/src/ui/legend/continuous/utils.ts +4 -7
- package/src/ui/legend/continuous.ts +43 -9
- package/src/ui/marker/index.ts +2 -1
- package/src/ui/tag/index.ts +0 -5
- package/src/ui/timebar/controller.ts +6 -9
- package/src/ui/title/index.ts +5 -8
- package/src/ui/tooltip/index.ts +5 -1
- package/src/util/group-by.ts +4 -7
|
@@ -2,7 +2,7 @@ import { CustomEvent } from '@antv/g';
|
|
|
2
2
|
import { Linear } from '@antv/scale';
|
|
3
3
|
import { clamp, isUndefined } from '@antv/util';
|
|
4
4
|
import { Component } from '../../core';
|
|
5
|
-
import type {
|
|
5
|
+
import type { DisplayObject, TextStyleProps } from '../../shapes';
|
|
6
6
|
import { Group } from '../../shapes';
|
|
7
7
|
import { Point } from '../../types';
|
|
8
8
|
import {
|
|
@@ -517,7 +517,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
517
517
|
else if (labelPosition === 'top') spacing = labelSpacing;
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
-
return { offset, spacing
|
|
520
|
+
return { offset, spacing, tickLength };
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
private adjustLabel() {
|
|
@@ -570,11 +570,13 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
570
570
|
data.map(({ value }) => value),
|
|
571
571
|
value
|
|
572
572
|
);
|
|
573
|
-
|
|
573
|
+
|
|
574
|
+
const selection = this.getRealSelection(range);
|
|
575
|
+
this.showIndicator((range[0] + range[1]) / 2, `${selection[0]}-${selection[1]}`);
|
|
574
576
|
this.dispatchIndicated(value, range);
|
|
575
577
|
} else {
|
|
576
578
|
const safetyValue = this.getTickValue(value);
|
|
577
|
-
this.showIndicator(safetyValue);
|
|
579
|
+
this.showIndicator(safetyValue, `${this.getRealValue(safetyValue)}`);
|
|
578
580
|
this.dispatchIndicated(safetyValue);
|
|
579
581
|
}
|
|
580
582
|
};
|
|
@@ -590,6 +592,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
590
592
|
const safeValue = clamp(value, min, max);
|
|
591
593
|
const offset = this.getOffset(safeValue);
|
|
592
594
|
const pos: Point = this.ifHorizontal([offset + x, y], [x, offset + y]);
|
|
595
|
+
|
|
593
596
|
this.indicator.update({
|
|
594
597
|
x: pos[0],
|
|
595
598
|
y: pos[1],
|
|
@@ -686,9 +689,8 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
686
689
|
|
|
687
690
|
/**
|
|
688
691
|
* 事件触发的位置对应的value值
|
|
689
|
-
* @param limit {boolean} 我也忘了要干啥了
|
|
690
692
|
*/
|
|
691
|
-
private getValueByCanvasPoint(e: any
|
|
693
|
+
private getValueByCanvasPoint(e: any) {
|
|
692
694
|
const { min, max } = this.range;
|
|
693
695
|
const [x, y] = this.ribbon.node().getPosition();
|
|
694
696
|
const startPos = this.ifHorizontal(x, y);
|
|
@@ -708,18 +710,50 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
708
710
|
return scale.map(value);
|
|
709
711
|
}
|
|
710
712
|
|
|
713
|
+
private getRealSelection(range: number[]) {
|
|
714
|
+
const { max } = this.range;
|
|
715
|
+
const [start, end] = range;
|
|
716
|
+
|
|
717
|
+
return this.ifHorizontal([start, end], [max - end, max - start]);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
private getRealValue(value: number) {
|
|
721
|
+
const { max } = this.range;
|
|
722
|
+
|
|
723
|
+
return this.ifHorizontal(value, max - value);
|
|
724
|
+
}
|
|
725
|
+
|
|
711
726
|
private dispatchSelection() {
|
|
727
|
+
const selection = this.getRealSelection(this.selection);
|
|
728
|
+
|
|
712
729
|
const evt = new CustomEvent('valuechange', {
|
|
713
730
|
detail: {
|
|
714
|
-
value:
|
|
731
|
+
value: selection,
|
|
715
732
|
},
|
|
716
733
|
});
|
|
717
734
|
this.dispatchEvent(evt as any);
|
|
718
735
|
}
|
|
719
736
|
|
|
720
|
-
private dispatchIndicated(value: number, range?:
|
|
737
|
+
private dispatchIndicated(value: number, range?: number[]) {
|
|
738
|
+
const { max } = this.range;
|
|
739
|
+
|
|
740
|
+
const detail = this.ifHorizontal(
|
|
741
|
+
() => {
|
|
742
|
+
return {
|
|
743
|
+
value,
|
|
744
|
+
range,
|
|
745
|
+
};
|
|
746
|
+
},
|
|
747
|
+
() => {
|
|
748
|
+
return {
|
|
749
|
+
value: max - value,
|
|
750
|
+
range: range ? this.getRealSelection(range) : undefined,
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
);
|
|
754
|
+
|
|
721
755
|
const evt = new CustomEvent('indicate', {
|
|
722
|
-
detail
|
|
756
|
+
detail,
|
|
723
757
|
});
|
|
724
758
|
this.dispatchEvent(evt as any);
|
|
725
759
|
}
|
package/src/ui/marker/index.ts
CHANGED
|
@@ -44,7 +44,8 @@ function getType(symbol: MarkerStyleProps['symbol']): string | null {
|
|
|
44
44
|
|
|
45
45
|
export class Marker extends Component<MarkerStyleProps> {
|
|
46
46
|
public render(attributes: Required<MarkerStyleProps>, container: Group) {
|
|
47
|
-
const {
|
|
47
|
+
const { x = 0, y = 0 } = attributes;
|
|
48
|
+
const { symbol, size = 16, ...style } = this.getSubShapeStyle(attributes);
|
|
48
49
|
|
|
49
50
|
const type = getType(symbol);
|
|
50
51
|
ifShow(!!type, select(container), (group) => {
|
package/src/ui/tag/index.ts
CHANGED
|
@@ -61,15 +61,10 @@ export class Tag extends Component<TagStyleProps> {
|
|
|
61
61
|
.style('zIndex', 0)
|
|
62
62
|
.node();
|
|
63
63
|
const markerStyle = marker || { symbol: 'triangle', size: 0 };
|
|
64
|
-
// @ts-ignore
|
|
65
64
|
const markerShape = maybeAppend(group, '.tag-marker', () => new Marker({ style: markerStyle }))
|
|
66
65
|
.attr('className', 'tag-marker')
|
|
67
|
-
.call((selection) => {
|
|
68
|
-
(selection.node() as Marker).clear();
|
|
69
|
-
})
|
|
70
66
|
.update(markerStyle)
|
|
71
67
|
.node() as Marker;
|
|
72
|
-
|
|
73
68
|
const { x, y } = getTextPosition(markerShape, spacing);
|
|
74
69
|
|
|
75
70
|
select(group)
|
|
@@ -64,15 +64,12 @@ export class Controller extends Component<ControllerStyleProps> {
|
|
|
64
64
|
padding: [, right, , left],
|
|
65
65
|
} = this;
|
|
66
66
|
|
|
67
|
-
const components = functions.reduce(
|
|
68
|
-
(prev
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
[] as (keyof typeof componentsMap)[]
|
|
75
|
-
);
|
|
67
|
+
const components = functions.reduce((prev, curr) => {
|
|
68
|
+
if (prev.length && curr.length) {
|
|
69
|
+
return prev.concat('split', ...curr);
|
|
70
|
+
}
|
|
71
|
+
return prev.concat(...curr);
|
|
72
|
+
}, [] as (keyof typeof componentsMap)[]);
|
|
76
73
|
|
|
77
74
|
const componentsWidth = components.length * (iconSize + iconSpacing) - iconSpacing;
|
|
78
75
|
const xOffset =
|
package/src/ui/title/index.ts
CHANGED
|
@@ -73,14 +73,11 @@ export function getBBox(title: Title, content: DisplayObject): DOMRect {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function mayApplyStyle(el: Selection, style: any) {
|
|
76
|
-
const finalStyle = Object.entries(style).reduce(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
{} as Record<string, any>
|
|
83
|
-
);
|
|
76
|
+
const finalStyle = Object.entries(style).reduce((acc, [key, value]) => {
|
|
77
|
+
const currAttr = el.node().attr(key);
|
|
78
|
+
if (!currAttr) acc[key] = value;
|
|
79
|
+
return acc;
|
|
80
|
+
}, {} as Record<string, any>);
|
|
84
81
|
|
|
85
82
|
el.styles(finalStyle);
|
|
86
83
|
}
|
package/src/ui/tooltip/index.ts
CHANGED
|
@@ -151,7 +151,11 @@ export class Tooltip extends Component<TooltipStyleProps> {
|
|
|
151
151
|
const itemsElements = this.HTMLTooltipItemsElements;
|
|
152
152
|
const ul = document.createElement('ul');
|
|
153
153
|
ul.className = CLASS_NAME.LIST;
|
|
154
|
-
ul.replaceChildren(...itemsElements);
|
|
154
|
+
if (ul.replaceChildren) ul.replaceChildren(...itemsElements);
|
|
155
|
+
else {
|
|
156
|
+
ul.innerHTML = '';
|
|
157
|
+
ul.append(...itemsElements);
|
|
158
|
+
}
|
|
155
159
|
const list = this.element.querySelector(`.${CLASS_NAME.LIST}`);
|
|
156
160
|
if (list) list.replaceWith(ul);
|
|
157
161
|
else container.appendChild(ul);
|
package/src/util/group-by.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export function groupBy<T extends { [key: string]: any }>(source: T[], by: keyof T) {
|
|
2
|
-
return source.reduce(
|
|
3
|
-
(acc
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
},
|
|
7
|
-
{} as { [key in T[keyof T]]: T[] }
|
|
8
|
-
);
|
|
2
|
+
return source.reduce((acc, curr) => {
|
|
3
|
+
(acc[curr[by]] = acc[curr[by]] || []).push(curr);
|
|
4
|
+
return acc;
|
|
5
|
+
}, {} as { [key in T[keyof T]]: T[] });
|
|
9
6
|
}
|