@antv/component 2.0.0 → 2.0.1
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 +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/checkbox/constant.d.ts +3 -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.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/icons.d.ts +2 -2
- 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/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/labels.d.ts +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/checkbox/constant.d.ts +3 -3
- package/lib/ui/grid/index.d.ts +1 -1
- package/lib/ui/legend/base.d.ts +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.d.ts +2 -1
- package/lib/ui/legend/continuous.js +30 -8
- package/lib/ui/legend/continuous.js.map +1 -1
- package/lib/ui/marker/index.js +2 -1
- package/lib/ui/marker/index.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/icons.d.ts +2 -2
- package/lib/util/keyframe-interpolate.d.ts +1 -1
- package/package.json +5 -5
- package/src/core/component.ts +5 -0
- package/src/ui/legend/category/item.ts +12 -5
- package/src/ui/legend/continuous.ts +43 -9
- package/src/ui/marker/index.ts +2 -1
- package/src/ui/tag/index.ts +0 -5
|
@@ -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)
|