@antv/component 1.0.1-beta.3 → 1.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/animation/utils.js +14 -10
- package/esm/animation/utils.js.map +1 -1
- package/esm/ui/axis/constant.js +2 -1
- package/esm/ui/axis/constant.js.map +1 -1
- package/esm/ui/axis/guides/labels.js +9 -11
- package/esm/ui/axis/guides/labels.js.map +1 -1
- package/esm/ui/axis/guides/line.js +2 -2
- package/esm/ui/axis/guides/line.js.map +1 -1
- package/esm/ui/axis/guides/ticks.js +1 -1
- package/esm/ui/axis/guides/ticks.js.map +1 -1
- package/esm/ui/axis/guides/title.js +9 -6
- package/esm/ui/axis/guides/title.js.map +1 -1
- package/esm/ui/axis/overlap/autoEllipsis.js +2 -1
- package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
- package/esm/ui/axis/overlap/autoHide.js +2 -1
- package/esm/ui/axis/overlap/autoHide.js.map +1 -1
- package/esm/ui/axis/utils/bounds.d.ts +1 -3
- package/esm/ui/axis/utils/bounds.js +7 -4
- package/esm/ui/axis/utils/bounds.js.map +1 -1
- package/esm/ui/breadcrumb/index.js +2 -2
- package/esm/ui/breadcrumb/index.js.map +1 -1
- package/esm/ui/button/index.js +6 -8
- package/esm/ui/button/index.js.map +1 -1
- package/esm/ui/button/types.d.ts +0 -2
- package/esm/ui/checkbox/constant.d.ts +3 -3
- package/esm/ui/checkbox/constant.js +1 -1
- package/esm/ui/checkbox/constant.js.map +1 -1
- package/esm/ui/checkbox/index.js +1 -1
- package/esm/ui/checkbox/index.js.map +1 -1
- package/esm/ui/crosshair/base.js +1 -1
- package/esm/ui/crosshair/base.js.map +1 -1
- package/esm/ui/crosshair/circle.js +1 -1
- package/esm/ui/crosshair/circle.js.map +1 -1
- package/esm/ui/crosshair/polygon.js +1 -1
- package/esm/ui/crosshair/polygon.js.map +1 -1
- package/esm/ui/grid/index.js +3 -3
- package/esm/ui/grid/index.js.map +1 -1
- package/esm/ui/indicator/indicator.js +2 -3
- package/esm/ui/indicator/indicator.js.map +1 -1
- package/esm/ui/indicator/types.d.ts +0 -2
- package/esm/ui/layout/layout.js +1 -3
- package/esm/ui/layout/layout.js.map +1 -1
- package/esm/ui/layout/types.d.ts +0 -2
- package/esm/ui/legend/category/item.d.ts +0 -2
- package/esm/ui/legend/category/item.js +4 -10
- package/esm/ui/legend/category/item.js.map +1 -1
- package/esm/ui/legend/category/items.d.ts +0 -2
- package/esm/ui/legend/category/items.js.map +1 -1
- package/esm/ui/legend/category.js +2 -4
- package/esm/ui/legend/category.js.map +1 -1
- package/esm/ui/legend/continuous/ribbon.js +4 -4
- package/esm/ui/legend/continuous/ribbon.js.map +1 -1
- package/esm/ui/legend/continuous.d.ts +1 -0
- package/esm/ui/legend/continuous.js +17 -5
- package/esm/ui/legend/continuous.js.map +1 -1
- package/esm/ui/marker/index.js +4 -4
- package/esm/ui/marker/index.js.map +1 -1
- package/esm/ui/marker/types.d.ts +0 -2
- package/esm/ui/navigator/index.js +1 -6
- package/esm/ui/navigator/index.js.map +1 -1
- package/esm/ui/navigator/types.d.ts +0 -2
- package/esm/ui/scrollbar/index.js +2 -4
- package/esm/ui/scrollbar/index.js.map +1 -1
- package/esm/ui/scrollbar/types.d.ts +0 -2
- package/esm/ui/select/option.js +1 -1
- package/esm/ui/select/option.js.map +1 -1
- package/esm/ui/select/select.js +9 -11
- package/esm/ui/select/select.js.map +1 -1
- package/esm/ui/select/types.d.ts +0 -4
- package/esm/ui/slider/constant.d.ts +0 -2
- package/esm/ui/slider/constant.js +0 -2
- package/esm/ui/slider/constant.js.map +1 -1
- package/esm/ui/slider/handle.d.ts +0 -4
- package/esm/ui/slider/handle.js +17 -14
- package/esm/ui/slider/handle.js.map +1 -1
- package/esm/ui/slider/index.js +16 -17
- package/esm/ui/slider/index.js.map +1 -1
- package/esm/ui/slider/types.d.ts +0 -2
- package/esm/ui/sparkline/columns.d.ts +0 -2
- package/esm/ui/sparkline/columns.js +1 -2
- package/esm/ui/sparkline/columns.js.map +1 -1
- package/esm/ui/sparkline/index.js +4 -6
- package/esm/ui/sparkline/index.js.map +1 -1
- package/esm/ui/sparkline/lines.d.ts +0 -2
- package/esm/ui/sparkline/lines.js +1 -2
- package/esm/ui/sparkline/lines.js.map +1 -1
- package/esm/ui/sparkline/types.d.ts +0 -2
- package/esm/ui/switch/index.js +0 -1
- package/esm/ui/switch/index.js.map +1 -1
- package/esm/ui/switch/types.d.ts +0 -2
- package/esm/ui/tag/index.js +0 -1
- package/esm/ui/tag/index.js.map +1 -1
- package/esm/ui/tag/types.d.ts +0 -2
- package/esm/ui/timebar/controller.js +8 -8
- package/esm/ui/timebar/controller.js.map +1 -1
- package/esm/ui/timebar/handle.d.ts +0 -4
- package/esm/ui/timebar/handle.js +7 -9
- package/esm/ui/timebar/handle.js.map +1 -1
- package/esm/ui/timebar/icons.js +91 -104
- package/esm/ui/timebar/icons.js.map +1 -1
- package/esm/ui/timebar/timebar.js +6 -14
- package/esm/ui/timebar/timebar.js.map +1 -1
- package/esm/ui/timebar/types.d.ts +0 -4
- package/esm/ui/tooltip/types.d.ts +0 -2
- package/esm/util/keyframe-interpolate.d.ts +1 -1
- package/esm/util/offscreen.js +0 -1
- package/esm/util/offscreen.js.map +1 -1
- package/esm/util/primitive.js +3 -0
- package/esm/util/primitive.js.map +1 -1
- package/esm/util/scale-to-pixel.js +2 -3
- package/esm/util/scale-to-pixel.js.map +1 -1
- package/esm/util/text.d.ts +1 -6
- 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/animation/utils.js +14 -10
- package/lib/animation/utils.js.map +1 -1
- package/lib/ui/axis/constant.js +2 -1
- package/lib/ui/axis/constant.js.map +1 -1
- package/lib/ui/axis/guides/labels.js +9 -11
- package/lib/ui/axis/guides/labels.js.map +1 -1
- package/lib/ui/axis/guides/line.js +2 -2
- package/lib/ui/axis/guides/line.js.map +1 -1
- package/lib/ui/axis/guides/ticks.js +1 -1
- package/lib/ui/axis/guides/ticks.js.map +1 -1
- package/lib/ui/axis/guides/title.js +8 -5
- package/lib/ui/axis/guides/title.js.map +1 -1
- package/lib/ui/axis/overlap/autoEllipsis.js +2 -1
- package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
- package/lib/ui/axis/overlap/autoHide.js +2 -1
- package/lib/ui/axis/overlap/autoHide.js.map +1 -1
- package/lib/ui/axis/utils/bounds.d.ts +1 -3
- package/lib/ui/axis/utils/bounds.js +9 -5
- package/lib/ui/axis/utils/bounds.js.map +1 -1
- package/lib/ui/breadcrumb/index.js +2 -2
- package/lib/ui/breadcrumb/index.js.map +1 -1
- package/lib/ui/button/index.js +6 -8
- package/lib/ui/button/index.js.map +1 -1
- package/lib/ui/button/types.d.ts +0 -2
- package/lib/ui/checkbox/constant.d.ts +3 -3
- package/lib/ui/checkbox/constant.js +1 -1
- package/lib/ui/checkbox/constant.js.map +1 -1
- package/lib/ui/checkbox/index.js +1 -1
- package/lib/ui/checkbox/index.js.map +1 -1
- package/lib/ui/crosshair/base.js +1 -1
- package/lib/ui/crosshair/base.js.map +1 -1
- package/lib/ui/crosshair/circle.js +1 -1
- package/lib/ui/crosshair/circle.js.map +1 -1
- package/lib/ui/crosshair/polygon.js +1 -1
- package/lib/ui/crosshair/polygon.js.map +1 -1
- package/lib/ui/grid/index.js +3 -3
- package/lib/ui/grid/index.js.map +1 -1
- package/lib/ui/indicator/indicator.js +2 -3
- package/lib/ui/indicator/indicator.js.map +1 -1
- package/lib/ui/indicator/types.d.ts +0 -2
- package/lib/ui/layout/layout.js +1 -3
- package/lib/ui/layout/layout.js.map +1 -1
- package/lib/ui/layout/types.d.ts +0 -2
- package/lib/ui/legend/category/item.d.ts +0 -2
- package/lib/ui/legend/category/item.js +4 -10
- package/lib/ui/legend/category/item.js.map +1 -1
- package/lib/ui/legend/category/items.d.ts +0 -2
- package/lib/ui/legend/category/items.js.map +1 -1
- package/lib/ui/legend/category.js +2 -4
- package/lib/ui/legend/category.js.map +1 -1
- package/lib/ui/legend/continuous/ribbon.js +4 -4
- package/lib/ui/legend/continuous/ribbon.js.map +1 -1
- package/lib/ui/legend/continuous.d.ts +1 -0
- package/lib/ui/legend/continuous.js +17 -5
- package/lib/ui/legend/continuous.js.map +1 -1
- package/lib/ui/marker/index.js +4 -4
- package/lib/ui/marker/index.js.map +1 -1
- package/lib/ui/marker/types.d.ts +0 -2
- package/lib/ui/navigator/index.js +1 -6
- package/lib/ui/navigator/index.js.map +1 -1
- package/lib/ui/navigator/types.d.ts +0 -2
- package/lib/ui/scrollbar/index.js +2 -4
- package/lib/ui/scrollbar/index.js.map +1 -1
- package/lib/ui/scrollbar/types.d.ts +0 -2
- package/lib/ui/select/option.js +1 -1
- package/lib/ui/select/option.js.map +1 -1
- package/lib/ui/select/select.js +9 -11
- package/lib/ui/select/select.js.map +1 -1
- package/lib/ui/select/types.d.ts +0 -4
- package/lib/ui/slider/constant.d.ts +0 -2
- package/lib/ui/slider/constant.js +0 -2
- package/lib/ui/slider/constant.js.map +1 -1
- package/lib/ui/slider/handle.d.ts +0 -4
- package/lib/ui/slider/handle.js +17 -14
- package/lib/ui/slider/handle.js.map +1 -1
- package/lib/ui/slider/index.js +16 -17
- package/lib/ui/slider/index.js.map +1 -1
- package/lib/ui/slider/types.d.ts +0 -2
- package/lib/ui/sparkline/columns.d.ts +0 -2
- package/lib/ui/sparkline/columns.js +1 -2
- package/lib/ui/sparkline/columns.js.map +1 -1
- package/lib/ui/sparkline/index.js +4 -6
- package/lib/ui/sparkline/index.js.map +1 -1
- package/lib/ui/sparkline/lines.d.ts +0 -2
- package/lib/ui/sparkline/lines.js +1 -2
- package/lib/ui/sparkline/lines.js.map +1 -1
- package/lib/ui/sparkline/types.d.ts +0 -2
- package/lib/ui/switch/index.js +0 -1
- package/lib/ui/switch/index.js.map +1 -1
- package/lib/ui/switch/types.d.ts +0 -2
- package/lib/ui/tag/index.js +0 -1
- package/lib/ui/tag/index.js.map +1 -1
- package/lib/ui/tag/types.d.ts +0 -2
- package/lib/ui/timebar/controller.js +8 -8
- package/lib/ui/timebar/controller.js.map +1 -1
- package/lib/ui/timebar/handle.d.ts +0 -4
- package/lib/ui/timebar/handle.js +7 -9
- package/lib/ui/timebar/handle.js.map +1 -1
- package/lib/ui/timebar/icons.js +91 -104
- package/lib/ui/timebar/icons.js.map +1 -1
- package/lib/ui/timebar/timebar.js +6 -14
- package/lib/ui/timebar/timebar.js.map +1 -1
- package/lib/ui/timebar/types.d.ts +0 -4
- package/lib/ui/tooltip/types.d.ts +0 -2
- package/lib/util/keyframe-interpolate.d.ts +1 -1
- package/lib/util/offscreen.js +0 -1
- package/lib/util/offscreen.js.map +1 -1
- package/lib/util/primitive.js +3 -0
- package/lib/util/primitive.js.map +1 -1
- package/lib/util/scale-to-pixel.js +2 -3
- package/lib/util/scale-to-pixel.js.map +1 -1
- package/lib/util/text.d.ts +1 -6
- package/package.json +7 -6
- package/src/animation/utils.ts +15 -16
- package/src/ui/axis/constant.ts +2 -1
- package/src/ui/axis/guides/labels.ts +10 -18
- package/src/ui/axis/guides/line.ts +2 -2
- package/src/ui/axis/guides/ticks.ts +1 -1
- package/src/ui/axis/guides/title.ts +9 -9
- package/src/ui/axis/overlap/autoEllipsis.ts +2 -1
- package/src/ui/axis/overlap/autoHide.ts +2 -1
- package/src/ui/axis/utils/bounds.ts +7 -4
- package/src/ui/breadcrumb/index.ts +3 -2
- package/src/ui/button/index.ts +6 -10
- package/src/ui/button/types.ts +0 -2
- package/src/ui/checkbox/constant.ts +1 -1
- package/src/ui/checkbox/index.ts +2 -0
- package/src/ui/crosshair/base.ts +1 -1
- package/src/ui/crosshair/circle.ts +1 -1
- package/src/ui/crosshair/polygon.ts +1 -1
- package/src/ui/grid/index.ts +3 -3
- package/src/ui/indicator/indicator.ts +2 -3
- package/src/ui/indicator/types.ts +0 -2
- package/src/ui/layout/layout.ts +1 -4
- package/src/ui/layout/types.ts +0 -2
- package/src/ui/legend/category/item.ts +4 -14
- package/src/ui/legend/category/items.ts +0 -2
- package/src/ui/legend/category.ts +2 -4
- package/src/ui/legend/continuous/ribbon.ts +4 -4
- package/src/ui/legend/continuous.ts +20 -5
- package/src/ui/marker/index.ts +4 -5
- package/src/ui/marker/types.ts +0 -2
- package/src/ui/navigator/index.ts +1 -8
- package/src/ui/navigator/types.ts +0 -2
- package/src/ui/scrollbar/index.ts +1 -5
- package/src/ui/scrollbar/types.ts +0 -2
- package/src/ui/select/option.ts +1 -1
- package/src/ui/select/select.ts +9 -11
- package/src/ui/select/types.ts +0 -4
- package/src/ui/slider/constant.ts +0 -2
- package/src/ui/slider/handle.ts +14 -26
- package/src/ui/slider/index.ts +12 -20
- package/src/ui/slider/types.ts +0 -2
- package/src/ui/sparkline/columns.ts +1 -4
- package/src/ui/sparkline/index.ts +4 -10
- package/src/ui/sparkline/lines.ts +1 -4
- package/src/ui/sparkline/types.ts +0 -2
- package/src/ui/switch/index.ts +0 -1
- package/src/ui/switch/types.ts +0 -2
- package/src/ui/tag/index.ts +0 -1
- package/src/ui/tag/types.ts +0 -2
- package/src/ui/timebar/controller.ts +8 -8
- package/src/ui/timebar/handle.ts +10 -16
- package/src/ui/timebar/icons.ts +87 -94
- package/src/ui/timebar/timebar.ts +9 -13
- package/src/ui/timebar/types.ts +0 -4
- package/src/ui/tooltip/types.ts +0 -2
- package/src/util/offscreen.ts +0 -1
- package/src/util/primitive.ts +3 -0
- package/src/util/scale-to-pixel.ts +1 -3
|
@@ -42,8 +42,6 @@ export type CategoryItemStyleProps = GroupStyleProps &
|
|
|
42
42
|
valueText?: ExtendDisplayObject;
|
|
43
43
|
// if width and height not specific, set it to actual space occurred
|
|
44
44
|
width?: number;
|
|
45
|
-
x?: number;
|
|
46
|
-
y?: number;
|
|
47
45
|
};
|
|
48
46
|
|
|
49
47
|
export type CategoryItemOptions = ComponentOptions<CategoryItemStyleProps>;
|
|
@@ -198,8 +196,7 @@ export class CategoryItem extends Component<CategoryItemStyleProps> {
|
|
|
198
196
|
|
|
199
197
|
// record the scale of marker
|
|
200
198
|
this.markerGroup.node().scale(1 / this.markerGroup.node().getScale()[0]);
|
|
201
|
-
|
|
202
|
-
this.markerGroup.node().style._transform = `scale(${scale})`;
|
|
199
|
+
scaleToPixel(this.markerGroup.node(), this.scaleSize, true);
|
|
203
200
|
});
|
|
204
201
|
}
|
|
205
202
|
|
|
@@ -234,25 +231,18 @@ export class CategoryItem extends Component<CategoryItemStyleProps> {
|
|
|
234
231
|
},
|
|
235
232
|
} = this;
|
|
236
233
|
const halfHeight = height / 2;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this.markerGroup.styles({
|
|
241
|
-
transform: `translate(${markerX}, ${halfHeight})${this.markerGroup.node().style._transform}`,
|
|
242
|
-
});
|
|
243
|
-
this.labelGroup.styles({ transform: `translate(${labelX}, ${halfHeight})` });
|
|
234
|
+
this.markerGroup.styles({ x: markerX, y: halfHeight });
|
|
235
|
+
this.labelGroup.styles({ x: labelX, y: halfHeight });
|
|
244
236
|
|
|
245
237
|
ellipsisIt(this.labelGroup.select(CLASS_NAMES.label.class).node(), Math.ceil(labelWidth));
|
|
246
238
|
if (this.showValue) {
|
|
247
|
-
this.valueGroup.styles({
|
|
239
|
+
this.valueGroup.styles({ x: valueX, y: halfHeight });
|
|
248
240
|
ellipsisIt(this.valueGroup.select(CLASS_NAMES.value.class).node(), Math.ceil(valueWidth));
|
|
249
241
|
}
|
|
250
242
|
}
|
|
251
243
|
|
|
252
244
|
public render(attributes: CategoryItemStyleProps, container: Group) {
|
|
253
245
|
const ctn = select(container);
|
|
254
|
-
const { x = 0, y = 0 } = attributes;
|
|
255
|
-
ctn.styles({ transform: `translate(${x}, ${y})` });
|
|
256
246
|
this.renderMarker(ctn);
|
|
257
247
|
this.renderLabel(ctn);
|
|
258
248
|
this.renderValue(ctn);
|
|
@@ -66,8 +66,7 @@ export class Category extends Component<CategoryStyleProps> {
|
|
|
66
66
|
const { showTitle } = this.attributes;
|
|
67
67
|
if (showTitle) {
|
|
68
68
|
const { x, y } = this.title.node<Title>().getAvailableSpace();
|
|
69
|
-
this.itemsGroup.node().
|
|
70
|
-
// this.itemsGroup.node().setLocalPosition(x, y);
|
|
69
|
+
this.itemsGroup.node().setLocalPosition(x, y);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
|
|
@@ -85,9 +84,8 @@ export class Category extends Component<CategoryStyleProps> {
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
render(attributes: Required<CategoryStyleProps>, container: Group) {
|
|
88
|
-
const { width, height
|
|
87
|
+
const { width, height } = attributes;
|
|
89
88
|
const ctn = select(container);
|
|
90
|
-
container.style.transform = `translate(${x}, ${y})`;
|
|
91
89
|
|
|
92
90
|
this.renderTitle(ctn, width!, height!);
|
|
93
91
|
|
|
@@ -93,7 +93,7 @@ function getClipPath(attr: RequiredRibbonStyleProps): any[] {
|
|
|
93
93
|
|
|
94
94
|
function renderTrack(container: Selection, attr: RequiredRibbonStyleProps) {
|
|
95
95
|
const style = subStyleProps(attr, 'track');
|
|
96
|
-
container.maybeAppendByClassName(CLASS_NAMES.track, 'path').styles({
|
|
96
|
+
container.maybeAppendByClassName(CLASS_NAMES.track, 'path').styles({ path: getTrackPath(attr), ...style });
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function renderSelection(container: Selection, attr: RequiredRibbonStyleProps) {
|
|
@@ -102,12 +102,12 @@ function renderSelection(container: Selection, attr: RequiredRibbonStyleProps) {
|
|
|
102
102
|
|
|
103
103
|
const ribbon = container
|
|
104
104
|
.maybeAppendByClassName(CLASS_NAMES.selection, 'path')
|
|
105
|
-
.styles({
|
|
105
|
+
.styles({ path: getSelectionPath(attr), fill, ...style });
|
|
106
106
|
const clipPath = ribbon
|
|
107
107
|
.maybeAppendByClassName(CLASS_NAMES.clipPath, 'path')
|
|
108
|
-
.styles({
|
|
108
|
+
.styles({ path: getClipPath(attr) })
|
|
109
109
|
.node();
|
|
110
|
-
ribbon.style('
|
|
110
|
+
ribbon.style('clip-path', clipPath);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export class Ribbon extends Component<RibbonStyleProps> {
|
|
@@ -92,9 +92,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
92
92
|
/** label */
|
|
93
93
|
|
|
94
94
|
/** content */
|
|
95
|
-
const contentGroup = select(container)
|
|
96
|
-
.maybeAppendByClassName(CLASS_NAMES.contentGroup, 'g')
|
|
97
|
-
.styles({ transform: `translate(${x}, ${y})` });
|
|
95
|
+
const contentGroup = select(container).maybeAppendByClassName(CLASS_NAMES.contentGroup, 'g').styles({ x, y });
|
|
98
96
|
|
|
99
97
|
const labelGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles({ zIndex: 1 });
|
|
100
98
|
ifShow(!!showLabel, labelGroup, (group) => {
|
|
@@ -270,7 +268,8 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
270
268
|
const { length, size } = this.ribbonShape;
|
|
271
269
|
const style: Required<RibbonStyleProps> = deepAssign(
|
|
272
270
|
{
|
|
273
|
-
|
|
271
|
+
x,
|
|
272
|
+
y,
|
|
274
273
|
length,
|
|
275
274
|
size,
|
|
276
275
|
type,
|
|
@@ -345,6 +344,22 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
345
344
|
this.setHandlePosition('end', max);
|
|
346
345
|
}
|
|
347
346
|
|
|
347
|
+
private adjustTitle() {
|
|
348
|
+
const { titlePosition, orientation } = this.attributes;
|
|
349
|
+
const [title] = this.getElementsByClassName(CLASS_NAMES.title.name);
|
|
350
|
+
const handle: Handle = this.handlesGroup.select(`.${this.getHandleClassName('start')}`).node();
|
|
351
|
+
if (!title || !handle) return;
|
|
352
|
+
if (titlePosition !== 'top-left' || orientation !== 'horizontal') return;
|
|
353
|
+
const {
|
|
354
|
+
min: [handleX],
|
|
355
|
+
} = handle.getLocalBounds();
|
|
356
|
+
const {
|
|
357
|
+
min: [titleX],
|
|
358
|
+
} = title.getLocalBounds();
|
|
359
|
+
const diffX = handleX - titleX;
|
|
360
|
+
title.style.x = +(this.style.x || 0) + diffX;
|
|
361
|
+
}
|
|
362
|
+
|
|
348
363
|
private cacheHandleBBox: DOMRect | null = null;
|
|
349
364
|
|
|
350
365
|
private get handleBBox() {
|
|
@@ -376,7 +391,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
|
|
|
376
391
|
[ribbonX + ribbonSize * this.handleOffsetRatio, ribbonY + offset]
|
|
377
392
|
);
|
|
378
393
|
const handle: Handle = this.handlesGroup.select(`.${this.getHandleClassName(type)}`).node();
|
|
379
|
-
handle?.update({
|
|
394
|
+
handle?.update({ x, y, formatter: handleFormatter });
|
|
380
395
|
}
|
|
381
396
|
|
|
382
397
|
private renderIndicator(container: Selection) {
|
package/src/ui/marker/index.ts
CHANGED
|
@@ -44,8 +44,7 @@ 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 { symbol, size = 16,
|
|
48
|
-
|
|
47
|
+
const { symbol, size = 16, ...style } = attributes;
|
|
49
48
|
const type = getType(symbol);
|
|
50
49
|
ifShow(!!type, select(container), (group) => {
|
|
51
50
|
group
|
|
@@ -59,13 +58,13 @@ export class Marker extends Component<MarkerStyleProps> {
|
|
|
59
58
|
img: symbol,
|
|
60
59
|
width: r,
|
|
61
60
|
height: r,
|
|
62
|
-
x:
|
|
63
|
-
y:
|
|
61
|
+
x: -size,
|
|
62
|
+
y: -size,
|
|
64
63
|
});
|
|
65
64
|
} else {
|
|
66
65
|
const r = (size as number) / 2;
|
|
67
66
|
const symbolFn = isFunction(symbol) ? symbol : Marker.getSymbol(symbol);
|
|
68
|
-
selection.styles({
|
|
67
|
+
selection.styles({ path: symbolFn?.(0, 0, r), ...style });
|
|
69
68
|
}
|
|
70
69
|
});
|
|
71
70
|
});
|
package/src/ui/marker/types.ts
CHANGED
|
@@ -4,8 +4,6 @@ import type { BaseCustomElementStyleProps } from '../../shapes';
|
|
|
4
4
|
export type FunctionalSymbol = (x: number, y: number, r: number) => any;
|
|
5
5
|
|
|
6
6
|
export type MarkerStyleProps = BaseCustomElementStyleProps & {
|
|
7
|
-
x?: number;
|
|
8
|
-
y?: number;
|
|
9
7
|
size?: number;
|
|
10
8
|
symbol: string | FunctionalSymbol;
|
|
11
9
|
};
|
|
@@ -41,8 +41,6 @@ const CLASS_NAMES = classNames(
|
|
|
41
41
|
export class Navigator extends Component<NavigatorStyleProps> {
|
|
42
42
|
constructor(options: NavigatorOptions) {
|
|
43
43
|
super(options, {
|
|
44
|
-
x: 0,
|
|
45
|
-
y: 0,
|
|
46
44
|
animate: {
|
|
47
45
|
easing: 'linear',
|
|
48
46
|
duration: 200,
|
|
@@ -50,7 +48,7 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
50
48
|
},
|
|
51
49
|
buttonCursor: 'pointer',
|
|
52
50
|
buttonFill: 'black',
|
|
53
|
-
|
|
51
|
+
buttonPath: button(0, 0, 6),
|
|
54
52
|
buttonSize: 12,
|
|
55
53
|
controllerPadding: 5,
|
|
56
54
|
controllerSpacing: 5,
|
|
@@ -307,8 +305,6 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
307
305
|
|
|
308
306
|
this.updatePageInfo();
|
|
309
307
|
|
|
310
|
-
// group.node().style.transform = `translate(${pageWidth + spacing}, ${pageHeight / 2})`;
|
|
311
|
-
|
|
312
308
|
// put it on the right side of the container
|
|
313
309
|
group.node().setLocalPosition(pageWidth + spacing, pageHeight / 2);
|
|
314
310
|
if (whetherToAddEventListener) {
|
|
@@ -322,9 +318,6 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
322
318
|
}
|
|
323
319
|
|
|
324
320
|
render(attributes: NavigatorStyleProps, container: Group) {
|
|
325
|
-
const { x = 0, y = 0 } = attributes;
|
|
326
|
-
this.attr('transform', `translate(${x}, ${y})`);
|
|
327
|
-
|
|
328
321
|
/**
|
|
329
322
|
* container
|
|
330
323
|
* |- contentGroup (with clip path)
|
|
@@ -6,8 +6,6 @@ import type { PrefixObject } from '../../types';
|
|
|
6
6
|
export type NavigatorStyleProps = Omit<RectStyleProps, 'width' | 'height'> &
|
|
7
7
|
PrefixObject<PathStyleProps & { size?: number }, 'button'> &
|
|
8
8
|
PrefixObject<TextStyleProps, 'pageNum'> & {
|
|
9
|
-
x?: number;
|
|
10
|
-
y?: number;
|
|
11
9
|
animate?: GenericAnimation;
|
|
12
10
|
/** padding between buttons and page number */
|
|
13
11
|
controllerPadding?: number;
|
|
@@ -23,8 +23,6 @@ export class Scrollbar extends Component<ScrollbarStyleProps> {
|
|
|
23
23
|
|
|
24
24
|
constructor(options: ScrollbarOptions) {
|
|
25
25
|
super(options, {
|
|
26
|
-
x: 0,
|
|
27
|
-
y: 0,
|
|
28
26
|
isRound: true,
|
|
29
27
|
orientation: 'vertical',
|
|
30
28
|
padding: [2, 2, 2, 2],
|
|
@@ -92,13 +90,11 @@ export class Scrollbar extends Component<ScrollbarStyleProps> {
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
private renderSlider(container: Group) {
|
|
95
|
-
const {
|
|
93
|
+
const { orientation, trackSize, padding, slidable } = this.attributes;
|
|
96
94
|
const trackStyle = subStyleProps<RectStyleProps>(this.attributes, 'track');
|
|
97
95
|
const selectionStyle = subStyleProps<RectStyleProps>(this.attributes, 'thumb');
|
|
98
96
|
|
|
99
97
|
const style: SliderStyleProps = {
|
|
100
|
-
x,
|
|
101
|
-
y,
|
|
102
98
|
brushable: false,
|
|
103
99
|
orientation,
|
|
104
100
|
padding,
|
|
@@ -8,8 +8,6 @@ import type { SliderStyleProps } from '../slider';
|
|
|
8
8
|
export type ScrollbarStyleProps = GroupStyleProps &
|
|
9
9
|
PrefixObject<RectStyleProps, 'track'> &
|
|
10
10
|
PrefixObject<RectStyleProps, 'thumb'> & {
|
|
11
|
-
x?: number;
|
|
12
|
-
y?: number;
|
|
13
11
|
/** 滑条朝向 */
|
|
14
12
|
orientation?: Required<SliderStyleProps>['orientation'];
|
|
15
13
|
|
package/src/ui/select/option.ts
CHANGED
|
@@ -52,7 +52,7 @@ export class Option extends Component<OptionStyleProps> {
|
|
|
52
52
|
fill: selected ? this.selectedColor : '#fff',
|
|
53
53
|
});
|
|
54
54
|
// place label
|
|
55
|
-
this.label.attr({
|
|
55
|
+
this.label.attr({ x: left, y: (backgroundHeight - labelHeight) / 2 });
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
constructor(options: OptionOptions) {
|
package/src/ui/select/select.ts
CHANGED
|
@@ -9,8 +9,6 @@ import type { SelectOptions, SelectStyleProps } from './types';
|
|
|
9
9
|
export class Select extends Component<SelectStyleProps> {
|
|
10
10
|
static defaultOptions: SelectOptions = {
|
|
11
11
|
style: {
|
|
12
|
-
x: 0,
|
|
13
|
-
y: 0,
|
|
14
12
|
width: 140,
|
|
15
13
|
height: 32,
|
|
16
14
|
options: [],
|
|
@@ -76,10 +74,10 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
76
74
|
);
|
|
77
75
|
|
|
78
76
|
private renderSelect() {
|
|
79
|
-
const {
|
|
77
|
+
const { width, height, bordered, showDropdownIcon } = this.style;
|
|
80
78
|
const selectStyle = subStyleProps(this.attributes, 'select');
|
|
81
79
|
const placeholderStyle = subStyleProps(this.attributes, 'placeholder');
|
|
82
|
-
this.select.attr({
|
|
80
|
+
this.select.attr({ width, height, ...selectStyle, fill: '#fff', strokeWidth: bordered ? 1 : 0 });
|
|
83
81
|
const padding = this.dropdownPadding;
|
|
84
82
|
// dropdown icon
|
|
85
83
|
const iconSize = 10;
|
|
@@ -87,7 +85,7 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
87
85
|
select(this.select)
|
|
88
86
|
.maybeAppend('.dropdown-icon', 'path')
|
|
89
87
|
.style('d', 'M-5,-3.5 L0,3.5 L5,-3.5')
|
|
90
|
-
.style('transform', `translate(${
|
|
88
|
+
.style('transform', `translate(${width - iconSize - padding[1] - padding[3]}, ${height / 2})`)
|
|
91
89
|
.style('lineWidth', 1)
|
|
92
90
|
.style('stroke', this.select.style.stroke);
|
|
93
91
|
}
|
|
@@ -95,7 +93,7 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
95
93
|
const currentOption = this.style.options?.find((option) => option.value === this.currentValue);
|
|
96
94
|
// placeholder
|
|
97
95
|
const finalPlaceholderStyle = {
|
|
98
|
-
x:
|
|
96
|
+
x: padding[3],
|
|
99
97
|
...placeholderStyle,
|
|
100
98
|
};
|
|
101
99
|
select(this.select)
|
|
@@ -109,7 +107,7 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
109
107
|
.styles(finalPlaceholderStyle)
|
|
110
108
|
.style('y', function () {
|
|
111
109
|
const bbox = this.getBBox();
|
|
112
|
-
return
|
|
110
|
+
return (height - bbox.height) / 2;
|
|
113
111
|
}),
|
|
114
112
|
(update) => update.styles(finalPlaceholderStyle),
|
|
115
113
|
(exit) => exit.remove()
|
|
@@ -118,7 +116,7 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
118
116
|
// value
|
|
119
117
|
const labelStyle = subStyleProps(this.attributes, 'optionLabel');
|
|
120
118
|
const finalValueStyle = {
|
|
121
|
-
x:
|
|
119
|
+
x: padding[3],
|
|
122
120
|
...labelStyle,
|
|
123
121
|
};
|
|
124
122
|
|
|
@@ -133,7 +131,7 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
133
131
|
.styles(finalValueStyle)
|
|
134
132
|
.style('y', function () {
|
|
135
133
|
const bbox = this.getBBox();
|
|
136
|
-
return
|
|
134
|
+
return (height - bbox.height) / 2;
|
|
137
135
|
}),
|
|
138
136
|
(update) => update.styles(finalValueStyle),
|
|
139
137
|
(exit) => exit.remove()
|
|
@@ -141,7 +139,7 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
private renderDropdown() {
|
|
144
|
-
const {
|
|
142
|
+
const { width, height, options, onSelect, open } = this.style;
|
|
145
143
|
const dropdownStyle = subStyleProps(this.attributes, 'dropdown');
|
|
146
144
|
const optionStyle = subStyleProps(this.attributes, 'option');
|
|
147
145
|
const padding = this.dropdownPadding;
|
|
@@ -195,7 +193,7 @@ export class Select extends Component<SelectStyleProps> {
|
|
|
195
193
|
const { spacing } = dropdownStyle;
|
|
196
194
|
|
|
197
195
|
this.dropdown.attr({
|
|
198
|
-
|
|
196
|
+
y: height + spacing,
|
|
199
197
|
width: bbox.width + padding[1] + padding[3],
|
|
200
198
|
height: bbox.height + padding[0] + padding[2],
|
|
201
199
|
...dropdownStyle,
|
package/src/ui/select/types.ts
CHANGED
|
@@ -28,10 +28,6 @@ export type SelectStyleProps = GroupStyleProps &
|
|
|
28
28
|
PrefixObject<Omit<RectStyleProps, 'width' | 'height'>, 'dropdown'> &
|
|
29
29
|
PrefixObject<TextStyleProps, 'option'> &
|
|
30
30
|
PrefixObject<Omit<OptionStyleProps, 'value' | 'label' | 'selected' | 'onClick'>, 'option'> & {
|
|
31
|
-
/** 左上角 X 坐标 */
|
|
32
|
-
x?: number;
|
|
33
|
-
/** 左上角 Y 坐标 */
|
|
34
|
-
y?: number;
|
|
35
31
|
/** 宽度 */
|
|
36
32
|
width?: number;
|
|
37
33
|
/** 高度 */
|
package/src/ui/slider/handle.ts
CHANGED
|
@@ -8,8 +8,6 @@ import { HANDLE_DEFAULT_CFG, HANDLE_ICON_DEFAULT_CFG, HANDLE_LABEL_DEFAULT_CFG }
|
|
|
8
8
|
export type HandleType = 'start' | 'end';
|
|
9
9
|
|
|
10
10
|
export type IconStyleProps = PathStyleProps & {
|
|
11
|
-
x?: number;
|
|
12
|
-
y?: number;
|
|
13
11
|
size?: number;
|
|
14
12
|
radius?: number;
|
|
15
13
|
shape?: string | ((type: HandleType) => DisplayObject);
|
|
@@ -21,8 +19,6 @@ export type LabelStyleProps = Partial<TextStyleProps>;
|
|
|
21
19
|
export type HandleStyleProps = GroupStyleProps &
|
|
22
20
|
PrefixStyleProps<LabelStyleProps, 'label'> &
|
|
23
21
|
PrefixStyleProps<IconStyleProps, 'icon'> & {
|
|
24
|
-
x?: number;
|
|
25
|
-
y?: number;
|
|
26
22
|
orientation?: IconStyleProps['orientation'];
|
|
27
23
|
showLabel?: boolean;
|
|
28
24
|
spacing?: number;
|
|
@@ -45,7 +41,7 @@ const CLASS_NAMES = classNames(
|
|
|
45
41
|
|
|
46
42
|
class HandleIcon extends Component<IconStyleProps> {
|
|
47
43
|
render(attributes: Required<IconStyleProps>, container: DisplayObject) {
|
|
48
|
-
const {
|
|
44
|
+
const { size = 10, radius = size / 4, orientation, ...iconStyle } = attributes;
|
|
49
45
|
// 默认手柄
|
|
50
46
|
const width = size!;
|
|
51
47
|
const height = width * 2.4;
|
|
@@ -57,20 +53,21 @@ class HandleIcon extends Component<IconStyleProps> {
|
|
|
57
53
|
width,
|
|
58
54
|
height,
|
|
59
55
|
radius,
|
|
60
|
-
x:
|
|
61
|
-
y:
|
|
62
|
-
transformOrigin: 'center',
|
|
56
|
+
x: -width / 2,
|
|
57
|
+
y: -height / 2,
|
|
63
58
|
});
|
|
64
59
|
|
|
65
|
-
const x1 =
|
|
66
|
-
const x2 =
|
|
67
|
-
const y1 =
|
|
68
|
-
const y2 =
|
|
60
|
+
const x1 = (1 / 3) * width;
|
|
61
|
+
const x2 = (2 / 3) * width;
|
|
62
|
+
const y1 = (1 / 4) * height;
|
|
63
|
+
const y2 = (3 / 4) * height;
|
|
69
64
|
|
|
70
65
|
rect.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-1`, 'line').styles({ x1, x2: x1, y1, y2, ...iconStyle });
|
|
71
66
|
rect.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-2`, 'line').styles({ x1: x2, x2, y1, y2, ...iconStyle });
|
|
72
67
|
|
|
73
|
-
|
|
68
|
+
rect.node().setOrigin(width / 2, height / 2);
|
|
69
|
+
if (orientation === 'vertical') container.setLocalEulerAngles(90);
|
|
70
|
+
else container.setLocalEulerAngles(0);
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
73
|
|
|
@@ -84,14 +81,8 @@ export class Handle extends Component<HandleStyleProps> {
|
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
private renderLabel(container: Group) {
|
|
87
|
-
const {
|
|
88
|
-
const {
|
|
89
|
-
x: labelX = 0,
|
|
90
|
-
y: labelY = 0,
|
|
91
|
-
transform,
|
|
92
|
-
transformOrigin,
|
|
93
|
-
...style
|
|
94
|
-
} = subStyleProps(this.attributes, 'label');
|
|
84
|
+
const { showLabel } = this.attributes;
|
|
85
|
+
const { transform, ...style } = subStyleProps(this.attributes, 'label');
|
|
95
86
|
const [labelStyle, groupStyle] = splitStyle(style, []);
|
|
96
87
|
|
|
97
88
|
const labelGroup = select(container).maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles(groupStyle);
|
|
@@ -101,10 +92,7 @@ export class Handle extends Component<HandleStyleProps> {
|
|
|
101
92
|
ifShow(!!showLabel, labelGroup, (group) => {
|
|
102
93
|
this.label = group.maybeAppendByClassName(CLASS_NAMES.label, 'text').styles({
|
|
103
94
|
...rest,
|
|
104
|
-
x: x + labelX,
|
|
105
|
-
y: y + labelY,
|
|
106
95
|
transform,
|
|
107
|
-
transformOrigin,
|
|
108
96
|
text: `${text}`,
|
|
109
97
|
});
|
|
110
98
|
|
|
@@ -119,8 +107,8 @@ export class Handle extends Component<HandleStyleProps> {
|
|
|
119
107
|
}
|
|
120
108
|
|
|
121
109
|
private renderIcon(container: Group) {
|
|
122
|
-
const {
|
|
123
|
-
const iconStyle = {
|
|
110
|
+
const { orientation, type } = this.attributes;
|
|
111
|
+
const iconStyle = { orientation, ...HANDLE_ICON_DEFAULT_CFG, ...subStyleProps(this.attributes, 'icon') };
|
|
124
112
|
const { iconShape = () => new HandleIcon({ style: iconStyle }) } = this.attributes;
|
|
125
113
|
const iconGroup = select(container).maybeAppendByClassName(CLASS_NAMES.iconGroup, 'g');
|
|
126
114
|
iconGroup
|
package/src/ui/slider/index.ts
CHANGED
|
@@ -83,7 +83,7 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
private get availableSpace() {
|
|
86
|
-
const {
|
|
86
|
+
const { padding } = this.attributes;
|
|
87
87
|
const [top, right, bottom, left] = parseSeriesAttr(padding!);
|
|
88
88
|
const { width, height } = this.shape;
|
|
89
89
|
return {
|
|
@@ -96,8 +96,6 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
96
96
|
|
|
97
97
|
constructor(options: SliderOptions) {
|
|
98
98
|
super(options, {
|
|
99
|
-
x: 0,
|
|
100
|
-
y: 0,
|
|
101
99
|
animate: { duration: 100, fill: 'both' },
|
|
102
100
|
brushable: true,
|
|
103
101
|
formatter: (val: any) => val.toString(),
|
|
@@ -169,21 +167,18 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
169
167
|
}
|
|
170
168
|
|
|
171
169
|
private renderTrack(container: Group) {
|
|
172
|
-
const { x, y } = this.attributes;
|
|
173
170
|
const style = subStyleProps(this.attributes, 'track');
|
|
174
171
|
|
|
175
172
|
this.trackShape = select(container)
|
|
176
173
|
.maybeAppendByClassName(CLASS_NAMES.track, 'rect')
|
|
177
|
-
.styles({
|
|
174
|
+
.styles({ ...this.shape, ...style });
|
|
178
175
|
}
|
|
179
176
|
|
|
180
177
|
private renderBrushArea(container: Group) {
|
|
181
|
-
const {
|
|
178
|
+
const { brushable } = this.attributes;
|
|
182
179
|
this.brushArea = select(container)
|
|
183
180
|
.maybeAppendByClassName(CLASS_NAMES.brushArea, 'rect')
|
|
184
181
|
.styles({
|
|
185
|
-
x,
|
|
186
|
-
y,
|
|
187
182
|
fill: 'transparent',
|
|
188
183
|
cursor: brushable ? 'crosshair' : 'default',
|
|
189
184
|
...this.shape,
|
|
@@ -191,11 +186,11 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
191
186
|
}
|
|
192
187
|
|
|
193
188
|
private renderSparkline(container: Group) {
|
|
194
|
-
const {
|
|
189
|
+
const { orientation } = this.attributes;
|
|
195
190
|
const sparklineGroup = select(container).maybeAppendByClassName(CLASS_NAMES.sparklineGroup, 'g');
|
|
196
191
|
|
|
197
192
|
ifShow(orientation === 'horizontal', sparklineGroup, (group) => {
|
|
198
|
-
const style =
|
|
193
|
+
const style = this.sparklineStyle!;
|
|
199
194
|
group.maybeAppendByClassName(CLASS_NAMES.sparkline, () => new Sparkline({ style })).update(style);
|
|
200
195
|
});
|
|
201
196
|
}
|
|
@@ -237,7 +232,7 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
237
232
|
}
|
|
238
233
|
|
|
239
234
|
private renderSelection(container: Group) {
|
|
240
|
-
const {
|
|
235
|
+
const { type, selectionType } = this.attributes;
|
|
241
236
|
this.foregroundGroup = select(container).maybeAppendByClassName(CLASS_NAMES.foreground, 'g');
|
|
242
237
|
|
|
243
238
|
// value 类型的 slider 不渲染选区
|
|
@@ -250,10 +245,7 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
250
245
|
if (selectionType === 'invert') return 'crosshair';
|
|
251
246
|
return 'default';
|
|
252
247
|
})
|
|
253
|
-
.styles(
|
|
254
|
-
...selectionStyle,
|
|
255
|
-
transform: `translate(${x}, ${y})`,
|
|
256
|
-
});
|
|
248
|
+
.styles(selectionStyle);
|
|
257
249
|
};
|
|
258
250
|
|
|
259
251
|
const that = this;
|
|
@@ -389,8 +381,8 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
389
381
|
private inferTextStyle(handleType: HandleType): Record<string, any> {
|
|
390
382
|
const { orientation } = this.attributes;
|
|
391
383
|
if (orientation === 'horizontal') return {};
|
|
392
|
-
if (handleType === 'start') return {
|
|
393
|
-
if (handleType === 'end') return {
|
|
384
|
+
if (handleType === 'start') return { transform: 'rotate(90)', textAlign: 'start' };
|
|
385
|
+
if (handleType === 'end') return { transform: 'rotate(90)', textAlign: 'end' };
|
|
394
386
|
return {};
|
|
395
387
|
}
|
|
396
388
|
|
|
@@ -478,8 +470,8 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
478
470
|
}
|
|
479
471
|
|
|
480
472
|
private getHandleStyle(handleType: HandleType): HandleStyleProps {
|
|
481
|
-
const {
|
|
482
|
-
const
|
|
473
|
+
const { showLabel, showLabelOnInteraction, orientation } = this.attributes;
|
|
474
|
+
const handlePosition = this.calcHandlePosition(handleType);
|
|
483
475
|
const textStyle = this.calcHandleText(handleType);
|
|
484
476
|
|
|
485
477
|
let internalShowLabel = showLabel;
|
|
@@ -491,7 +483,7 @@ export class Slider extends Component<SliderStyleProps> {
|
|
|
491
483
|
return {
|
|
492
484
|
...superStyleProps(this.getHandleIconStyle(), 'icon'),
|
|
493
485
|
...superStyleProps({ ...this.getHandleLabelStyle(handleType), ...textStyle }, 'label'),
|
|
494
|
-
|
|
486
|
+
...handlePosition,
|
|
495
487
|
orientation,
|
|
496
488
|
showLabel: internalShowLabel,
|
|
497
489
|
type: handleType,
|
package/src/ui/slider/types.ts
CHANGED
|
@@ -21,8 +21,6 @@ export type SliderStyleProps = GroupStyleProps &
|
|
|
21
21
|
PrefixObject<RectStyleProps, 'selection'> &
|
|
22
22
|
HandleStyleProps &
|
|
23
23
|
Partial<PrefixStyleProps<Omit<SparklineStyleProps, 'width' | 'height'>, 'sparkline'>> & {
|
|
24
|
-
x?: number;
|
|
25
|
-
y?: number;
|
|
26
24
|
/** 动画配置 */
|
|
27
25
|
animate?: GenericAnimation;
|
|
28
26
|
|
|
@@ -5,8 +5,6 @@ import { deepAssign, select } from '../../util';
|
|
|
5
5
|
export type ColumnStyleProps = GroupStyleProps;
|
|
6
6
|
|
|
7
7
|
export interface ColumnsStyleProps extends BaseStyleProps {
|
|
8
|
-
x?: number;
|
|
9
|
-
y?: number;
|
|
10
8
|
columns: ColumnStyleProps[][];
|
|
11
9
|
}
|
|
12
10
|
|
|
@@ -21,8 +19,7 @@ export class Columns extends DisplayObject<ColumnsStyleProps> {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
public render(): void {
|
|
24
|
-
const { columns
|
|
25
|
-
this.columnsGroup.style.transform = `translate(${x}, ${y})`;
|
|
22
|
+
const { columns } = this.attributes;
|
|
26
23
|
|
|
27
24
|
select(this.columnsGroup)
|
|
28
25
|
.selectAll('.column')
|
|
@@ -90,13 +90,13 @@ export class Sparkline extends Component<SparklineStyleProps> {
|
|
|
90
90
|
lines: lines.map((line, idx) => {
|
|
91
91
|
return {
|
|
92
92
|
stroke: this.getColor(idx),
|
|
93
|
-
|
|
93
|
+
path: smooth ? lineToCurvePath(line) : lineToLinePath(line),
|
|
94
94
|
...lineStyle,
|
|
95
95
|
};
|
|
96
96
|
}) as any,
|
|
97
97
|
areas: areas.map((path, idx) => {
|
|
98
98
|
return {
|
|
99
|
-
|
|
99
|
+
path,
|
|
100
100
|
fill: this.getColor(idx),
|
|
101
101
|
...areaStyle,
|
|
102
102
|
};
|
|
@@ -155,8 +155,6 @@ export class Sparkline extends Component<SparklineStyleProps> {
|
|
|
155
155
|
constructor(options: SparklineOptions) {
|
|
156
156
|
super(options, {
|
|
157
157
|
type: 'line',
|
|
158
|
-
x: 0,
|
|
159
|
-
y: 0,
|
|
160
158
|
width: 200,
|
|
161
159
|
height: 20,
|
|
162
160
|
isStack: false,
|
|
@@ -175,13 +173,9 @@ export class Sparkline extends Component<SparklineStyleProps> {
|
|
|
175
173
|
public render(attributes: Required<SparklineStyleProps>, container: Group) {
|
|
176
174
|
maybeAppend(container, '.container', 'rect').attr('className', 'container').node();
|
|
177
175
|
|
|
178
|
-
const { type
|
|
176
|
+
const { type } = attributes;
|
|
179
177
|
const className = `spark${type}`;
|
|
180
|
-
const style: any =
|
|
181
|
-
x,
|
|
182
|
-
y,
|
|
183
|
-
...(type === 'line' ? this.linesStyle : this.columnsStyle),
|
|
184
|
-
};
|
|
178
|
+
const style: any = type === 'line' ? this.linesStyle : this.columnsStyle;
|
|
185
179
|
|
|
186
180
|
select(container)
|
|
187
181
|
.selectAll('.spark')
|