@antv/component 1.0.1-beta.2 → 1.0.1-beta.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/animation/utils.js +10 -14
- package/esm/animation/utils.js.map +1 -1
- package/esm/ui/axis/axis.d.ts +1 -1
- package/esm/ui/axis/constant.js +1 -2
- package/esm/ui/axis/constant.js.map +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/labels.js +11 -9
- 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.d.ts +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.d.ts +1 -1
- package/esm/ui/axis/guides/title.js +6 -9
- package/esm/ui/axis/guides/title.js.map +1 -1
- package/esm/ui/axis/overlap/autoEllipsis.js +1 -2
- package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
- package/esm/ui/axis/overlap/autoHide.js +1 -2
- package/esm/ui/axis/overlap/autoHide.js.map +1 -1
- package/esm/ui/axis/utils/bounds.d.ts +3 -1
- package/esm/ui/axis/utils/bounds.js +4 -7
- 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 +8 -6
- package/esm/ui/button/index.js.map +1 -1
- package/esm/ui/button/types.d.ts +2 -0
- package/esm/ui/checkbox/constant.d.ts +4 -4
- 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.d.ts +1 -1
- package/esm/ui/grid/index.js +4 -4
- package/esm/ui/grid/index.js.map +1 -1
- package/esm/ui/indicator/indicator.js +3 -2
- package/esm/ui/indicator/indicator.js.map +1 -1
- package/esm/ui/indicator/types.d.ts +2 -0
- package/esm/ui/layout/layout.js +3 -1
- package/esm/ui/layout/layout.js.map +1 -1
- package/esm/ui/layout/types.d.ts +2 -0
- package/esm/ui/legend/base.d.ts +1 -1
- package/esm/ui/legend/category/item.d.ts +2 -0
- package/esm/ui/legend/category/item.js +10 -4
- package/esm/ui/legend/category/item.js.map +1 -1
- package/esm/ui/legend/category/items.d.ts +2 -0
- package/esm/ui/legend/category/items.js.map +1 -1
- package/esm/ui/legend/category.js +4 -3
- 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 +0 -1
- package/esm/ui/legend/continuous.js +5 -17
- 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 +2 -0
- package/esm/ui/navigator/index.js +6 -1
- package/esm/ui/navigator/index.js.map +1 -1
- package/esm/ui/navigator/types.d.ts +2 -0
- package/esm/ui/scrollbar/index.js +4 -2
- package/esm/ui/scrollbar/index.js.map +1 -1
- package/esm/ui/scrollbar/types.d.ts +2 -0
- package/esm/ui/select/option.js +1 -1
- package/esm/ui/select/option.js.map +1 -1
- package/esm/ui/select/select.js +11 -9
- package/esm/ui/select/select.js.map +1 -1
- package/esm/ui/select/types.d.ts +4 -0
- package/esm/ui/slider/constant.d.ts +2 -0
- package/esm/ui/slider/constant.js +2 -0
- package/esm/ui/slider/constant.js.map +1 -1
- package/esm/ui/slider/handle.d.ts +4 -0
- package/esm/ui/slider/handle.js +14 -17
- package/esm/ui/slider/handle.js.map +1 -1
- package/esm/ui/slider/index.js +18 -16
- package/esm/ui/slider/index.js.map +1 -1
- package/esm/ui/slider/types.d.ts +2 -0
- package/esm/ui/sparkline/columns.d.ts +2 -0
- package/esm/ui/sparkline/columns.js +2 -1
- package/esm/ui/sparkline/columns.js.map +1 -1
- package/esm/ui/sparkline/index.js +6 -4
- package/esm/ui/sparkline/index.js.map +1 -1
- package/esm/ui/sparkline/lines.d.ts +2 -0
- package/esm/ui/sparkline/lines.js +2 -1
- package/esm/ui/sparkline/lines.js.map +1 -1
- package/esm/ui/sparkline/types.d.ts +2 -0
- package/esm/ui/switch/index.js +1 -0
- package/esm/ui/switch/index.js.map +1 -1
- package/esm/ui/switch/types.d.ts +2 -0
- package/esm/ui/tag/index.js +1 -0
- package/esm/ui/tag/index.js.map +1 -1
- package/esm/ui/tag/types.d.ts +2 -0
- package/esm/ui/timebar/controller.js +8 -8
- package/esm/ui/timebar/controller.js.map +1 -1
- package/esm/ui/timebar/handle.d.ts +4 -0
- package/esm/ui/timebar/handle.js +9 -7
- package/esm/ui/timebar/handle.js.map +1 -1
- package/esm/ui/timebar/icons.d.ts +2 -2
- package/esm/ui/timebar/icons.js +104 -91
- package/esm/ui/timebar/icons.js.map +1 -1
- package/esm/ui/timebar/timebar.js +14 -6
- package/esm/ui/timebar/timebar.js.map +1 -1
- package/esm/ui/timebar/types.d.ts +4 -0
- package/esm/ui/tooltip/types.d.ts +2 -0
- package/esm/util/keyframe-interpolate.d.ts +1 -1
- package/esm/util/number.d.ts +2 -2
- package/esm/util/offscreen.js +1 -0
- package/esm/util/offscreen.js.map +1 -1
- package/esm/util/primitive.js +0 -3
- package/esm/util/primitive.js.map +1 -1
- package/esm/util/scale-to-pixel.js +3 -2
- package/esm/util/scale-to-pixel.js.map +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/animation/utils.js +10 -14
- package/lib/animation/utils.js.map +1 -1
- package/lib/ui/axis/axis.d.ts +1 -1
- package/lib/ui/axis/constant.js +1 -2
- package/lib/ui/axis/constant.js.map +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/labels.js +11 -9
- 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.d.ts +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.d.ts +1 -1
- package/lib/ui/axis/guides/title.js +5 -8
- package/lib/ui/axis/guides/title.js.map +1 -1
- package/lib/ui/axis/overlap/autoEllipsis.js +1 -2
- package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
- package/lib/ui/axis/overlap/autoHide.js +1 -2
- package/lib/ui/axis/overlap/autoHide.js.map +1 -1
- package/lib/ui/axis/utils/bounds.d.ts +3 -1
- package/lib/ui/axis/utils/bounds.js +5 -9
- 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 +8 -6
- package/lib/ui/button/index.js.map +1 -1
- package/lib/ui/button/types.d.ts +2 -0
- package/lib/ui/checkbox/constant.d.ts +4 -4
- 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.d.ts +1 -1
- package/lib/ui/grid/index.js +4 -4
- package/lib/ui/grid/index.js.map +1 -1
- package/lib/ui/indicator/indicator.js +3 -2
- package/lib/ui/indicator/indicator.js.map +1 -1
- package/lib/ui/indicator/types.d.ts +2 -0
- package/lib/ui/layout/layout.js +3 -1
- package/lib/ui/layout/layout.js.map +1 -1
- package/lib/ui/layout/types.d.ts +2 -0
- package/lib/ui/legend/base.d.ts +1 -1
- package/lib/ui/legend/category/item.d.ts +2 -0
- package/lib/ui/legend/category/item.js +10 -4
- package/lib/ui/legend/category/item.js.map +1 -1
- package/lib/ui/legend/category/items.d.ts +2 -0
- package/lib/ui/legend/category/items.js.map +1 -1
- package/lib/ui/legend/category.js +4 -3
- 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 +0 -1
- package/lib/ui/legend/continuous.js +5 -17
- 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 +2 -0
- package/lib/ui/navigator/index.js +6 -1
- package/lib/ui/navigator/index.js.map +1 -1
- package/lib/ui/navigator/types.d.ts +2 -0
- package/lib/ui/scrollbar/index.js +4 -2
- package/lib/ui/scrollbar/index.js.map +1 -1
- package/lib/ui/scrollbar/types.d.ts +2 -0
- package/lib/ui/select/option.js +1 -1
- package/lib/ui/select/option.js.map +1 -1
- package/lib/ui/select/select.js +11 -9
- package/lib/ui/select/select.js.map +1 -1
- package/lib/ui/select/types.d.ts +4 -0
- package/lib/ui/slider/constant.d.ts +2 -0
- package/lib/ui/slider/constant.js +2 -0
- package/lib/ui/slider/constant.js.map +1 -1
- package/lib/ui/slider/handle.d.ts +4 -0
- package/lib/ui/slider/handle.js +14 -17
- package/lib/ui/slider/handle.js.map +1 -1
- package/lib/ui/slider/index.js +18 -16
- package/lib/ui/slider/index.js.map +1 -1
- package/lib/ui/slider/types.d.ts +2 -0
- package/lib/ui/sparkline/columns.d.ts +2 -0
- package/lib/ui/sparkline/columns.js +2 -1
- package/lib/ui/sparkline/columns.js.map +1 -1
- package/lib/ui/sparkline/index.js +6 -4
- package/lib/ui/sparkline/index.js.map +1 -1
- package/lib/ui/sparkline/lines.d.ts +2 -0
- package/lib/ui/sparkline/lines.js +2 -1
- package/lib/ui/sparkline/lines.js.map +1 -1
- package/lib/ui/sparkline/types.d.ts +2 -0
- package/lib/ui/switch/index.js +1 -0
- package/lib/ui/switch/index.js.map +1 -1
- package/lib/ui/switch/types.d.ts +2 -0
- package/lib/ui/tag/index.js +1 -0
- package/lib/ui/tag/index.js.map +1 -1
- package/lib/ui/tag/types.d.ts +2 -0
- package/lib/ui/timebar/controller.js +8 -8
- package/lib/ui/timebar/controller.js.map +1 -1
- package/lib/ui/timebar/handle.d.ts +4 -0
- package/lib/ui/timebar/handle.js +9 -7
- package/lib/ui/timebar/handle.js.map +1 -1
- package/lib/ui/timebar/icons.d.ts +2 -2
- package/lib/ui/timebar/icons.js +104 -91
- package/lib/ui/timebar/icons.js.map +1 -1
- package/lib/ui/timebar/timebar.js +14 -6
- package/lib/ui/timebar/timebar.js.map +1 -1
- package/lib/ui/timebar/types.d.ts +4 -0
- package/lib/ui/tooltip/types.d.ts +2 -0
- package/lib/util/keyframe-interpolate.d.ts +1 -1
- package/lib/util/number.d.ts +2 -2
- package/lib/util/offscreen.js +1 -0
- package/lib/util/offscreen.js.map +1 -1
- package/lib/util/primitive.js +0 -3
- package/lib/util/primitive.js.map +1 -1
- package/lib/util/scale-to-pixel.js +3 -2
- package/lib/util/scale-to-pixel.js.map +1 -1
- package/package.json +6 -7
- package/src/animation/utils.ts +16 -15
- package/src/ui/axis/constant.ts +1 -2
- package/src/ui/axis/guides/labels.ts +18 -10
- 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 +1 -2
- package/src/ui/axis/overlap/autoHide.ts +1 -2
- package/src/ui/axis/utils/bounds.ts +4 -7
- package/src/ui/breadcrumb/index.ts +2 -3
- package/src/ui/button/index.ts +10 -6
- package/src/ui/button/types.ts +2 -0
- package/src/ui/checkbox/constant.ts +1 -1
- package/src/ui/checkbox/index.ts +0 -2
- 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 +4 -4
- package/src/ui/indicator/indicator.ts +3 -2
- package/src/ui/indicator/types.ts +2 -0
- package/src/ui/layout/layout.ts +4 -1
- package/src/ui/layout/types.ts +2 -0
- package/src/ui/legend/category/item.ts +14 -4
- package/src/ui/legend/category/items.ts +2 -0
- package/src/ui/legend/category.ts +4 -3
- package/src/ui/legend/continuous/ribbon.ts +4 -4
- package/src/ui/legend/continuous.ts +5 -20
- package/src/ui/marker/index.ts +5 -4
- package/src/ui/marker/types.ts +2 -0
- package/src/ui/navigator/index.ts +8 -1
- package/src/ui/navigator/types.ts +2 -0
- package/src/ui/scrollbar/index.ts +5 -1
- package/src/ui/scrollbar/types.ts +2 -0
- package/src/ui/select/option.ts +1 -1
- package/src/ui/select/select.ts +11 -9
- package/src/ui/select/types.ts +4 -0
- package/src/ui/slider/constant.ts +2 -0
- package/src/ui/slider/handle.ts +26 -14
- package/src/ui/slider/index.ts +23 -13
- package/src/ui/slider/types.ts +2 -0
- package/src/ui/sparkline/columns.ts +4 -1
- package/src/ui/sparkline/index.ts +10 -4
- package/src/ui/sparkline/lines.ts +4 -1
- package/src/ui/sparkline/types.ts +2 -0
- package/src/ui/switch/index.ts +1 -0
- package/src/ui/switch/types.ts +2 -0
- package/src/ui/tag/index.ts +1 -0
- package/src/ui/tag/types.ts +2 -0
- package/src/ui/timebar/controller.ts +8 -8
- package/src/ui/timebar/handle.ts +16 -10
- package/src/ui/timebar/icons.ts +94 -87
- package/src/ui/timebar/timebar.ts +13 -9
- package/src/ui/timebar/types.ts +4 -0
- package/src/ui/tooltip/types.ts +2 -0
- package/src/util/offscreen.ts +1 -0
- package/src/util/primitive.ts +0 -3
- package/src/util/scale-to-pixel.ts +3 -1
|
@@ -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
|
+
d: 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
|
-
path,
|
|
99
|
+
d: path,
|
|
100
100
|
fill: this.getColor(idx),
|
|
101
101
|
...areaStyle,
|
|
102
102
|
};
|
|
@@ -155,6 +155,8 @@ 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,
|
|
158
160
|
width: 200,
|
|
159
161
|
height: 20,
|
|
160
162
|
isStack: false,
|
|
@@ -173,9 +175,13 @@ export class Sparkline extends Component<SparklineStyleProps> {
|
|
|
173
175
|
public render(attributes: Required<SparklineStyleProps>, container: Group) {
|
|
174
176
|
maybeAppend(container, '.container', 'rect').attr('className', 'container').node();
|
|
175
177
|
|
|
176
|
-
const { type } = attributes;
|
|
178
|
+
const { type, x, y } = attributes;
|
|
177
179
|
const className = `spark${type}`;
|
|
178
|
-
const style: any =
|
|
180
|
+
const style: any = {
|
|
181
|
+
x,
|
|
182
|
+
y,
|
|
183
|
+
...(type === 'line' ? this.linesStyle : this.columnsStyle),
|
|
184
|
+
};
|
|
179
185
|
|
|
180
186
|
select(container)
|
|
181
187
|
.selectAll('.spark')
|
|
@@ -4,6 +4,8 @@ import { DisplayObject, Group } from '../../shapes';
|
|
|
4
4
|
import { deepAssign, select } from '../../util';
|
|
5
5
|
|
|
6
6
|
export interface LinesStyleProps extends BaseStyleProps {
|
|
7
|
+
x?: number;
|
|
8
|
+
y?: number;
|
|
7
9
|
lines: PathStyleProps[];
|
|
8
10
|
areas: PathStyleProps[];
|
|
9
11
|
}
|
|
@@ -19,7 +21,8 @@ export class Lines extends DisplayObject<LinesStyleProps> {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
public render(): void {
|
|
22
|
-
const { lines, areas } = this.attributes;
|
|
24
|
+
const { lines, areas, x, y } = this.attributes;
|
|
25
|
+
this.style.transform = `translate(${x}, ${y})`;
|
|
23
26
|
if (lines) this.renderLines(lines);
|
|
24
27
|
if (areas) this.renderAreas(areas);
|
|
25
28
|
}
|
|
@@ -31,6 +31,8 @@ type ColumnStyleProps = CallableObject<PrefixObject<RectStyleProps, 'column'>, C
|
|
|
31
31
|
export type SparklineStyleProps = GroupStyleProps &
|
|
32
32
|
LineStyleProps &
|
|
33
33
|
ColumnStyleProps & {
|
|
34
|
+
x?: number;
|
|
35
|
+
y?: number;
|
|
34
36
|
color?: string | string[] | ((idx: number) => string);
|
|
35
37
|
data?: number[] | number[][];
|
|
36
38
|
isStack?: boolean;
|
package/src/ui/switch/index.ts
CHANGED
|
@@ -92,6 +92,7 @@ export class Switch extends Component<SwitchStyleProps> {
|
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
// 增加 整体宽度 需要对 tag 提前渲染获得 width 然后通过 width 计算 x 的位置
|
|
95
|
+
// @ts-ignore
|
|
95
96
|
const { max, min } = tagShape?.getLocalBounds() || {};
|
|
96
97
|
const width = max[0] - min[0] + sizeStyle.radius;
|
|
97
98
|
const height = max[1] - min[1];
|
package/src/ui/switch/types.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { ComponentOptions } from '../../core';
|
|
|
3
3
|
import type { TagStyleProps } from '../tag';
|
|
4
4
|
|
|
5
5
|
export type SwitchStyleProps = GroupStyleProps & {
|
|
6
|
+
x?: number;
|
|
7
|
+
y?: number;
|
|
6
8
|
/**
|
|
7
9
|
* @title 大小
|
|
8
10
|
* @description switch 开关组件大小。默认为: default, 高度大小等于 22px,宽度默认等于高度的两倍,会随着内部的子元素大小自动调整。
|
package/src/ui/tag/index.ts
CHANGED
package/src/ui/tag/types.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { MarkerStyleProps } from '../marker';
|
|
|
6
6
|
export type TagStyleProps = GroupStyleProps &
|
|
7
7
|
PrefixStyleProps<Omit<TextStyleProps, 'x' | 'y' | 'text'>, 'label'> &
|
|
8
8
|
PrefixStyleProps<Partial<RectStyleProps>, 'background'> & {
|
|
9
|
+
x?: number;
|
|
10
|
+
y?: number;
|
|
9
11
|
text?: string;
|
|
10
12
|
/** 水平对齐方式 */
|
|
11
13
|
align?: 'start' | 'center' | 'end';
|
|
@@ -19,6 +19,8 @@ const componentsMap: Record<Functions | 'split', { new (...args: any): DisplayOb
|
|
|
19
19
|
export class Controller extends Component<ControllerStyleProps> {
|
|
20
20
|
static defaultOptions: ControllerOptions = {
|
|
21
21
|
style: {
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0,
|
|
22
24
|
width: 300,
|
|
23
25
|
height: 40,
|
|
24
26
|
padding: 0,
|
|
@@ -50,13 +52,13 @@ export class Controller extends Component<ControllerStyleProps> {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
private renderBackground() {
|
|
53
|
-
const { width, height } = this.style;
|
|
55
|
+
const { x, y, width, height } = this.style;
|
|
54
56
|
const backgroundStyle = subStyleProps(this.attributes, 'background');
|
|
55
|
-
this.background.attr({ width, height, ...backgroundStyle });
|
|
57
|
+
this.background.attr({ x, y, width, height, ...backgroundStyle });
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
private renderFunctions() {
|
|
59
|
-
const { functions, iconSize, iconSpacing, width, height, align } = this.attributes;
|
|
61
|
+
const { functions, iconSize, iconSpacing, x, y, width, height, align } = this.attributes;
|
|
60
62
|
|
|
61
63
|
const {
|
|
62
64
|
padding: [, right, , left],
|
|
@@ -85,8 +87,8 @@ export class Controller extends Component<ControllerStyleProps> {
|
|
|
85
87
|
components.forEach((name, index) => {
|
|
86
88
|
const Ctor = componentsMap[name];
|
|
87
89
|
const style: Record<string, any> = {
|
|
88
|
-
x: index * (iconSize + iconSpacing) + xOffset,
|
|
89
|
-
y: height / 2,
|
|
90
|
+
x: x + index * (iconSize + iconSpacing) + xOffset,
|
|
91
|
+
y: y + height / 2,
|
|
90
92
|
size: iconSize,
|
|
91
93
|
};
|
|
92
94
|
|
|
@@ -105,11 +107,9 @@ export class Controller extends Component<ControllerStyleProps> {
|
|
|
105
107
|
|
|
106
108
|
if (Ctor === SpeedSelect) {
|
|
107
109
|
// SpeedSelect 直接插入到 canvas
|
|
108
|
-
const { x: baseX, y: baseY } = this.getBBox();
|
|
109
|
-
const { x, y } = style;
|
|
110
110
|
const canvas = this.ownerDocument?.defaultView;
|
|
111
111
|
if (canvas) {
|
|
112
|
-
this.speedSelect = new Ctor({ style: { ...style, zIndex: 100
|
|
112
|
+
this.speedSelect = new Ctor({ style: { ...style, zIndex: 100 } }) as SpeedSelect;
|
|
113
113
|
(canvas as unknown as Canvas).appendChild(this.speedSelect);
|
|
114
114
|
}
|
|
115
115
|
} else {
|
package/src/ui/timebar/handle.ts
CHANGED
|
@@ -40,6 +40,10 @@ type ChartModeHandleStyleProps = GroupStyleProps &
|
|
|
40
40
|
PrefixObject<Omit<RectStyleProps, 'x' | 'y' | 'width' | 'height'>, 'background'> &
|
|
41
41
|
PrefixObject<Omit<LineStyleProps, 'x1' | 'y1' | 'x2' | 'y2'>, 'icon'> &
|
|
42
42
|
PrefixObject<Omit<LineStyleProps, 'x1' | 'y1' | 'x2' | 'y2'>, 'border'> & {
|
|
43
|
+
x?: number;
|
|
44
|
+
y?: number;
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
43
47
|
/** 图标尺寸 */
|
|
44
48
|
iconSize?: number;
|
|
45
49
|
type: HandleType;
|
|
@@ -48,6 +52,8 @@ type ChartModeHandleOptions = ComponentOptions<ChartModeHandleStyleProps>;
|
|
|
48
52
|
export class ChartModeHandle extends Component<ChartModeHandleStyleProps> {
|
|
49
53
|
static defaultOptions: ChartModeHandleOptions = {
|
|
50
54
|
style: {
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0,
|
|
51
57
|
width: 10,
|
|
52
58
|
height: 50,
|
|
53
59
|
iconSize: 10,
|
|
@@ -62,41 +68,41 @@ export class ChartModeHandle extends Component<ChartModeHandleStyleProps> {
|
|
|
62
68
|
};
|
|
63
69
|
|
|
64
70
|
private renderBackground() {
|
|
65
|
-
const { width, height } = this.attributes;
|
|
71
|
+
const { x, y, width, height } = this.attributes;
|
|
66
72
|
const style = subStyleProps(this.attributes, 'background');
|
|
67
73
|
select(this)
|
|
68
74
|
.maybeAppend('background', 'rect')
|
|
69
75
|
.attr('className', 'background')
|
|
70
|
-
.styles({ x: -width / 2, y: -height / 2, width, height, ...style });
|
|
76
|
+
.styles({ x: x - width / 2, y: y - height / 2, width, height, ...style });
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
private renderIcon() {
|
|
74
|
-
const { iconSize } = this.attributes;
|
|
80
|
+
const { x, y, iconSize } = this.attributes;
|
|
75
81
|
const style = subStyleProps(this.attributes, 'icon');
|
|
76
82
|
const diffX = 1;
|
|
77
83
|
const diffY = iconSize / 2;
|
|
78
84
|
select(this)
|
|
79
85
|
.maybeAppend('icon-left-line', 'line')
|
|
80
86
|
.attr('className', 'icon-left-line')
|
|
81
|
-
.styles({ x1: -diffX, y1: -diffY, x2: -diffX, y2: diffY, ...style });
|
|
87
|
+
.styles({ x1: x - diffX, y1: y - diffY, x2: x - diffX, y2: y + diffY, ...style });
|
|
82
88
|
select(this)
|
|
83
89
|
.maybeAppend('icon-right-line', 'line')
|
|
84
90
|
.attr('className', 'icon-right-line')
|
|
85
|
-
.styles({ x1: diffX, y1: -diffY, x2: diffX, y2: diffY, ...style });
|
|
91
|
+
.styles({ x1: x + diffX, y1: y - diffY, x2: x + diffX, y2: y + diffY, ...style });
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
private renderBorder() {
|
|
89
|
-
const { width, height, type } = this.attributes;
|
|
95
|
+
const { x: xx, y, width, height, type } = this.attributes;
|
|
90
96
|
const style = subStyleProps(this.attributes, 'border');
|
|
91
97
|
const x = type === 'start' ? +width / 2 : -width / 2;
|
|
92
98
|
select(this)
|
|
93
99
|
.maybeAppend('border', 'line')
|
|
94
100
|
.attr('className', 'border')
|
|
95
101
|
.styles({
|
|
96
|
-
x1: x,
|
|
97
|
-
y1: -height / 2,
|
|
98
|
-
x2: x,
|
|
99
|
-
y2: +height / 2,
|
|
102
|
+
x1: x + xx,
|
|
103
|
+
y1: y - height / 2,
|
|
104
|
+
x2: x + xx,
|
|
105
|
+
y2: y + height / 2,
|
|
100
106
|
...style,
|
|
101
107
|
});
|
|
102
108
|
}
|
package/src/ui/timebar/icons.ts
CHANGED
|
@@ -66,10 +66,10 @@ export abstract class IconBase<T extends Record<string, any> = {}> extends Compo
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
protected renderBackground() {
|
|
69
|
-
const { size } = this.attributes;
|
|
69
|
+
const { x, y, size } = this.attributes;
|
|
70
70
|
const halfSize = size / 2;
|
|
71
71
|
const backgroundStyle = subStyleProps(this.attributes, 'background');
|
|
72
|
-
this.background.attr({ x: -halfSize, y: -halfSize, width: size, height: size, ...backgroundStyle });
|
|
72
|
+
this.background.attr({ x: x - halfSize, y: y - halfSize, width: size, height: size, ...backgroundStyle });
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
protected showIndicator() {
|
|
@@ -161,8 +161,7 @@ const arrow = (size: number, color: string = '#565758') => {
|
|
|
161
161
|
return new Path({
|
|
162
162
|
style: {
|
|
163
163
|
fill: color,
|
|
164
|
-
|
|
165
|
-
path: `M ${size},${size} L -${size},0 L ${size},-${size} Z`,
|
|
164
|
+
d: `M ${size},${size} L -${size},0 L ${size},-${size} Z`,
|
|
166
165
|
transformOrigin: 'center',
|
|
167
166
|
},
|
|
168
167
|
});
|
|
@@ -183,7 +182,7 @@ export class Reset extends IconBase {
|
|
|
183
182
|
}
|
|
184
183
|
|
|
185
184
|
renderIcon() {
|
|
186
|
-
const { color } = this.attributes;
|
|
185
|
+
const { x, y, color } = this.attributes;
|
|
187
186
|
const size = this.iconSize;
|
|
188
187
|
const { lineWidth } = this;
|
|
189
188
|
const arrowSize = lineWidth + 0.5;
|
|
@@ -193,7 +192,7 @@ export class Reset extends IconBase {
|
|
|
193
192
|
.styles({
|
|
194
193
|
stroke: color,
|
|
195
194
|
lineWidth,
|
|
196
|
-
|
|
195
|
+
d: this.arcPath(x, y, size / 2 - lineWidth),
|
|
197
196
|
markerStart: arrow(arrowSize, color),
|
|
198
197
|
});
|
|
199
198
|
}
|
|
@@ -206,19 +205,19 @@ export class Backward extends IconBase {
|
|
|
206
205
|
}
|
|
207
206
|
|
|
208
207
|
renderIcon() {
|
|
209
|
-
const { color } = this.attributes;
|
|
208
|
+
const { x, y, color } = this.attributes;
|
|
210
209
|
const size = this.iconSize;
|
|
211
210
|
const deltaX = size / 2;
|
|
212
211
|
const deltaY = size / 2 / 3 ** 0.5;
|
|
213
212
|
const points: PolygonStyleProps['points'] = [
|
|
214
|
-
[
|
|
215
|
-
[
|
|
216
|
-
[-deltaX,
|
|
217
|
-
[
|
|
218
|
-
[
|
|
219
|
-
[deltaX, -deltaY],
|
|
220
|
-
[deltaX, deltaY],
|
|
221
|
-
[
|
|
213
|
+
[x, y],
|
|
214
|
+
[x, y - deltaY],
|
|
215
|
+
[x - deltaX, y],
|
|
216
|
+
[x, y + deltaY],
|
|
217
|
+
[x, y],
|
|
218
|
+
[x + deltaX, y - deltaY],
|
|
219
|
+
[x + deltaX, y + deltaY],
|
|
220
|
+
[x, y],
|
|
222
221
|
];
|
|
223
222
|
select(this.icon).maybeAppend('.backward', 'polygon').styles({
|
|
224
223
|
points,
|
|
@@ -234,19 +233,19 @@ export class Forward extends IconBase {
|
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
renderIcon() {
|
|
237
|
-
const { color } = this.attributes;
|
|
236
|
+
const { x, y, color } = this.attributes;
|
|
238
237
|
const size = this.iconSize;
|
|
239
238
|
const deltaX = size / 2;
|
|
240
239
|
const deltaY = size / 2 / 3 ** 0.5;
|
|
241
240
|
const points: PolygonStyleProps['points'] = [
|
|
242
|
-
[
|
|
243
|
-
[
|
|
244
|
-
[deltaX,
|
|
245
|
-
[
|
|
246
|
-
[
|
|
247
|
-
[-deltaX, -deltaY],
|
|
248
|
-
[-deltaX, deltaY],
|
|
249
|
-
[
|
|
241
|
+
[x, y],
|
|
242
|
+
[x, y - deltaY],
|
|
243
|
+
[x + deltaX, y],
|
|
244
|
+
[x, y + deltaY],
|
|
245
|
+
[x, y],
|
|
246
|
+
[x - deltaX, y - deltaY],
|
|
247
|
+
[x - deltaX, y + deltaY],
|
|
248
|
+
[x, y],
|
|
250
249
|
];
|
|
251
250
|
select(this.icon).maybeAppend('.forward', 'polygon').styles({
|
|
252
251
|
points,
|
|
@@ -261,14 +260,14 @@ export class Play extends IconBase {
|
|
|
261
260
|
}
|
|
262
261
|
|
|
263
262
|
renderIcon() {
|
|
264
|
-
const { color } = this.attributes;
|
|
263
|
+
const { x, y, color } = this.attributes;
|
|
265
264
|
const size = this.iconSize;
|
|
266
265
|
const deltaX = (size / 3) * 3 ** 0.5 * 0.8;
|
|
267
266
|
const points: PolygonStyleProps['points'] = [
|
|
268
|
-
[deltaX,
|
|
269
|
-
[-deltaX / 2, -(size / 2) * 0.8],
|
|
270
|
-
[-deltaX / 2, (size / 2) * 0.8],
|
|
271
|
-
[deltaX,
|
|
267
|
+
[x + deltaX, y],
|
|
268
|
+
[x - deltaX / 2, y - (size / 2) * 0.8],
|
|
269
|
+
[x - deltaX / 2, y + (size / 2) * 0.8],
|
|
270
|
+
[x + deltaX, y],
|
|
272
271
|
];
|
|
273
272
|
select(this.icon).maybeAppend('.play', 'polygon').styles({
|
|
274
273
|
points,
|
|
@@ -283,19 +282,19 @@ export class Pause extends IconBase {
|
|
|
283
282
|
}
|
|
284
283
|
|
|
285
284
|
renderIcon() {
|
|
286
|
-
const { color } = this.attributes;
|
|
285
|
+
const { x, y, color } = this.attributes;
|
|
287
286
|
const size = this.iconSize;
|
|
288
287
|
const deltaX = size / 3;
|
|
289
288
|
const points: PolygonStyleProps['points'] = [
|
|
290
|
-
[-deltaX, -size / 2],
|
|
291
|
-
[-deltaX, size / 2],
|
|
292
|
-
[-deltaX / 2, size / 2],
|
|
293
|
-
[-deltaX / 2, -size / 2],
|
|
294
|
-
[-deltaX, -size / 2],
|
|
295
|
-
[deltaX / 2, -size / 2],
|
|
296
|
-
[deltaX / 2, size / 2],
|
|
297
|
-
[deltaX, size / 2],
|
|
298
|
-
[deltaX, -size / 2],
|
|
289
|
+
[x - deltaX, y - size / 2],
|
|
290
|
+
[x - deltaX, y + size / 2],
|
|
291
|
+
[x - deltaX / 2, y + size / 2],
|
|
292
|
+
[x - deltaX / 2, y - size / 2],
|
|
293
|
+
[x - deltaX, y - size / 2],
|
|
294
|
+
[x + deltaX / 2, y - size / 2],
|
|
295
|
+
[x + deltaX / 2, y + size / 2],
|
|
296
|
+
[x + deltaX, y + size / 2],
|
|
297
|
+
[x + deltaX, y - size / 2],
|
|
299
298
|
];
|
|
300
299
|
select(this.icon).maybeAppend('.pause', 'polygon').styles({
|
|
301
300
|
points,
|
|
@@ -311,17 +310,17 @@ export class Range extends IconBase {
|
|
|
311
310
|
}
|
|
312
311
|
|
|
313
312
|
renderIcon() {
|
|
314
|
-
const { color } = this.attributes;
|
|
313
|
+
const { x, y, color } = this.attributes;
|
|
315
314
|
const { iconSize: size, lineWidth } = this;
|
|
316
315
|
const gap = lineWidth;
|
|
317
316
|
|
|
318
317
|
select(this.icon)
|
|
319
318
|
.maybeAppend('.left-line', 'line')
|
|
320
319
|
.styles({
|
|
321
|
-
x1: -size / 2,
|
|
322
|
-
y1: -size / 2,
|
|
323
|
-
x2: -size / 2,
|
|
324
|
-
y2: size / 2,
|
|
320
|
+
x1: x - size / 2,
|
|
321
|
+
y1: y - size / 2,
|
|
322
|
+
x2: x - size / 2,
|
|
323
|
+
y2: y + size / 2,
|
|
325
324
|
stroke: color,
|
|
326
325
|
lineWidth,
|
|
327
326
|
});
|
|
@@ -329,10 +328,10 @@ export class Range extends IconBase {
|
|
|
329
328
|
select(this.icon)
|
|
330
329
|
.maybeAppend('.right-line', 'line')
|
|
331
330
|
.styles({
|
|
332
|
-
x1: size / 2,
|
|
333
|
-
y1: -size / 2,
|
|
334
|
-
x2: size / 2,
|
|
335
|
-
y2: size / 2,
|
|
331
|
+
x1: x + size / 2,
|
|
332
|
+
y1: y - size / 2,
|
|
333
|
+
x2: x + size / 2,
|
|
334
|
+
y2: y + size / 2,
|
|
336
335
|
stroke: color,
|
|
337
336
|
lineWidth,
|
|
338
337
|
});
|
|
@@ -340,10 +339,10 @@ export class Range extends IconBase {
|
|
|
340
339
|
select(this.icon)
|
|
341
340
|
.maybeAppend('.left-arrow', 'line')
|
|
342
341
|
.styles({
|
|
343
|
-
x1:
|
|
344
|
-
y1:
|
|
345
|
-
x2: -size / 2 + gap * 2,
|
|
346
|
-
y2:
|
|
342
|
+
x1: x,
|
|
343
|
+
y1: y,
|
|
344
|
+
x2: x - size / 2 + gap * 2,
|
|
345
|
+
y2: y,
|
|
347
346
|
stroke: color,
|
|
348
347
|
lineWidth,
|
|
349
348
|
markerEnd: arrow(lineWidth * 2, color),
|
|
@@ -352,10 +351,10 @@ export class Range extends IconBase {
|
|
|
352
351
|
select(this.icon)
|
|
353
352
|
.maybeAppend('.right-arrow', 'line')
|
|
354
353
|
.styles({
|
|
355
|
-
x1:
|
|
356
|
-
y1:
|
|
357
|
-
x2: size / 2 - gap * 2,
|
|
358
|
-
y2:
|
|
354
|
+
x1: x,
|
|
355
|
+
y1: y,
|
|
356
|
+
x2: x + size / 2 - gap * 2,
|
|
357
|
+
y2: y,
|
|
359
358
|
stroke: color,
|
|
360
359
|
lineWidth,
|
|
361
360
|
markerEnd: arrow(lineWidth * 2, color),
|
|
@@ -370,16 +369,16 @@ export class Value extends IconBase {
|
|
|
370
369
|
}
|
|
371
370
|
|
|
372
371
|
renderIcon() {
|
|
373
|
-
const { color } = this.attributes;
|
|
372
|
+
const { x, y, color } = this.attributes;
|
|
374
373
|
const { iconSize: size, lineWidth } = this;
|
|
375
374
|
|
|
376
375
|
select(this.icon)
|
|
377
376
|
.maybeAppend('.line', 'line')
|
|
378
377
|
.styles({
|
|
379
|
-
x1:
|
|
380
|
-
y1: -size / 2,
|
|
381
|
-
x2:
|
|
382
|
-
y2: size / 2,
|
|
378
|
+
x1: x,
|
|
379
|
+
y1: y - size / 2,
|
|
380
|
+
x2: x,
|
|
381
|
+
y2: y + size / 2,
|
|
383
382
|
stroke: color,
|
|
384
383
|
lineWidth,
|
|
385
384
|
});
|
|
@@ -389,10 +388,10 @@ export class Value extends IconBase {
|
|
|
389
388
|
select(this.icon)
|
|
390
389
|
.maybeAppend('.left-arrow', 'line')
|
|
391
390
|
.styles({
|
|
392
|
-
x1: -size / 2 - gap * 2,
|
|
393
|
-
y1:
|
|
394
|
-
x2: -gap * 2,
|
|
395
|
-
y2:
|
|
391
|
+
x1: x - size / 2 - gap * 2,
|
|
392
|
+
y1: y,
|
|
393
|
+
x2: x - gap * 2,
|
|
394
|
+
y2: y,
|
|
396
395
|
stroke: color,
|
|
397
396
|
lineWidth,
|
|
398
397
|
markerEnd: arrow(lineWidth * 2, color),
|
|
@@ -401,10 +400,10 @@ export class Value extends IconBase {
|
|
|
401
400
|
select(this.icon)
|
|
402
401
|
.maybeAppend('.right-arrow', 'line')
|
|
403
402
|
.styles({
|
|
404
|
-
x1: size / 2 + gap * 2,
|
|
405
|
-
y1:
|
|
406
|
-
x2: gap * 2,
|
|
407
|
-
y2:
|
|
403
|
+
x1: x + size / 2 + gap * 2,
|
|
404
|
+
y1: y,
|
|
405
|
+
x2: x + gap * 2,
|
|
406
|
+
y2: y,
|
|
408
407
|
stroke: color,
|
|
409
408
|
lineWidth,
|
|
410
409
|
markerEnd: arrow(lineWidth * 2, color),
|
|
@@ -426,18 +425,18 @@ export class LineChart extends IconBase {
|
|
|
426
425
|
}
|
|
427
426
|
|
|
428
427
|
renderIcon() {
|
|
429
|
-
const { color } = this.attributes;
|
|
428
|
+
const { x, y, color } = this.attributes;
|
|
430
429
|
const { iconSize: size, lineWidth } = this;
|
|
431
430
|
|
|
432
431
|
const gap = lineWidth;
|
|
433
432
|
const deltaX = (size - gap * 2 - lineWidth) / 4;
|
|
434
433
|
const deltaY = (size - gap * 2 - lineWidth) / 2;
|
|
435
|
-
const [ox, oy] = [-size / 2 + gap, size / 2 - gap * 2];
|
|
434
|
+
const [ox, oy] = [x - size / 2 + gap, y + size / 2 - gap * 2];
|
|
436
435
|
|
|
437
436
|
select(this.icon)
|
|
438
437
|
.maybeAppend('.coordinate', 'polyline')
|
|
439
438
|
.styles({
|
|
440
|
-
points: getCoordinatePoints(size),
|
|
439
|
+
points: getCoordinatePoints(size).map(([px, py]) => [px + x, py + y]),
|
|
441
440
|
stroke: color,
|
|
442
441
|
lineWidth,
|
|
443
442
|
});
|
|
@@ -468,18 +467,18 @@ export class BarChart extends IconBase {
|
|
|
468
467
|
|
|
469
468
|
renderIcon() {
|
|
470
469
|
const { data } = this;
|
|
471
|
-
const { color } = this.attributes;
|
|
470
|
+
const { x, y, color } = this.attributes;
|
|
472
471
|
const { iconSize: size, lineWidth } = this;
|
|
473
472
|
|
|
474
473
|
const gap = lineWidth;
|
|
475
474
|
const deltaX = (size - gap) / data.length;
|
|
476
475
|
const deltaY = (size - gap * 2) / 4;
|
|
477
|
-
const [ox, oy] = [-size / 2 + gap * 2, size / 2 - gap];
|
|
476
|
+
const [ox, oy] = [x - size / 2 + gap * 2, y + size / 2 - gap];
|
|
478
477
|
|
|
479
478
|
select(this.icon)
|
|
480
479
|
.maybeAppend('.coordinate', 'polyline')
|
|
481
480
|
.styles({
|
|
482
|
-
points: getCoordinatePoints(size),
|
|
481
|
+
points: getCoordinatePoints(size).map(([px, py]) => [px + x, py + y]),
|
|
483
482
|
stroke: color,
|
|
484
483
|
lineWidth,
|
|
485
484
|
});
|
|
@@ -514,15 +513,15 @@ export class Split extends IconBase {
|
|
|
514
513
|
}
|
|
515
514
|
|
|
516
515
|
renderIcon() {
|
|
517
|
-
const { color } = this.attributes;
|
|
516
|
+
const { x, y, color } = this.attributes;
|
|
518
517
|
const { iconSize: size, lineWidth } = this;
|
|
519
518
|
select(this.icon)
|
|
520
519
|
.maybeAppend('.split', 'line')
|
|
521
520
|
.styles({
|
|
522
|
-
x1:
|
|
523
|
-
y1: -size / 2,
|
|
524
|
-
x2:
|
|
525
|
-
y2: size / 2,
|
|
521
|
+
x1: x,
|
|
522
|
+
y1: y - size / 2,
|
|
523
|
+
x2: x,
|
|
524
|
+
y2: y + size / 2,
|
|
526
525
|
stroke: color,
|
|
527
526
|
lineWidth,
|
|
528
527
|
});
|
|
@@ -540,16 +539,24 @@ export class SpeedSelect extends IconBase<{ speed?: number; onSelect: SelectStyl
|
|
|
540
539
|
|
|
541
540
|
renderIcon() {
|
|
542
541
|
const { iconSize } = this;
|
|
543
|
-
const { speed = 1 } = this.attributes;
|
|
544
|
-
const inheritStyle = omit(this.attributes as any, [
|
|
542
|
+
const { x, y, speed = 1 } = this.attributes;
|
|
543
|
+
const inheritStyle = omit(this.attributes as any, [
|
|
544
|
+
'x',
|
|
545
|
+
'y',
|
|
546
|
+
'transform',
|
|
547
|
+
'transformOrigin',
|
|
548
|
+
'width',
|
|
549
|
+
'height',
|
|
550
|
+
'size',
|
|
551
|
+
'color',
|
|
552
|
+
'speed',
|
|
553
|
+
]);
|
|
545
554
|
const width = clamp(iconSize, 20, Infinity);
|
|
546
555
|
const height = 20;
|
|
547
|
-
const x = -width / 2;
|
|
548
|
-
const y = -height / 2;
|
|
549
556
|
const style: SelectStyleProps = {
|
|
550
557
|
...inheritStyle,
|
|
551
|
-
x,
|
|
552
|
-
y,
|
|
558
|
+
x: x - width / 2,
|
|
559
|
+
y: y - height / 2,
|
|
553
560
|
width,
|
|
554
561
|
height,
|
|
555
562
|
defaultValue: speed,
|
|
@@ -605,7 +612,7 @@ export abstract class ToggleIcon<T extends string> extends Component<ToggleIconS
|
|
|
605
612
|
}
|
|
606
613
|
|
|
607
614
|
render() {
|
|
608
|
-
const {
|
|
615
|
+
const { onChange, ...restStyles } = this.attributes;
|
|
609
616
|
select(this.icon)
|
|
610
617
|
.selectAll('.icon')
|
|
611
618
|
.data([this.currentType])
|
|
@@ -18,6 +18,8 @@ type States = Pick<TimebarStyleProps, 'speed' | 'selectionType' | 'chartType' |
|
|
|
18
18
|
export class Timebar extends Component<TimebarStyleProps> {
|
|
19
19
|
static defaultOptions: TimebarOptions = {
|
|
20
20
|
style: {
|
|
21
|
+
x: 0,
|
|
22
|
+
y: 0,
|
|
21
23
|
axisLabelFill: '#6e6e6e',
|
|
22
24
|
axisLabelTextAlign: 'left',
|
|
23
25
|
axisLabelTextBaseline: 'top',
|
|
@@ -75,10 +77,10 @@ export class Timebar extends Component<TimebarStyleProps> {
|
|
|
75
77
|
|
|
76
78
|
/** 计算空间分配 */
|
|
77
79
|
private get space() {
|
|
78
|
-
const { width, height, type, controllerHeight } = this.attributes;
|
|
80
|
+
const { x, y, width, height, type, controllerHeight } = this.attributes;
|
|
79
81
|
|
|
80
82
|
const availableTimelineHeight = clamp(+height - controllerHeight, 0, +height);
|
|
81
|
-
const controllerBBox = new BBox(
|
|
83
|
+
const controllerBBox = new BBox(x, y + +height - controllerHeight, +width, controllerHeight);
|
|
82
84
|
|
|
83
85
|
// chart 模式下可用
|
|
84
86
|
let axisBBox: BBox;
|
|
@@ -86,13 +88,13 @@ export class Timebar extends Component<TimebarStyleProps> {
|
|
|
86
88
|
if (type === 'chart') {
|
|
87
89
|
// axis 默认分配高度为 35
|
|
88
90
|
axisHeight = 35;
|
|
89
|
-
axisBBox = new BBox(
|
|
91
|
+
axisBBox = new BBox(x, y + availableTimelineHeight - axisHeight, +width, axisHeight);
|
|
90
92
|
} else axisBBox = new BBox();
|
|
91
93
|
|
|
92
94
|
const timelineHeight = type === 'time' ? 10 : availableTimelineHeight;
|
|
93
95
|
const timelineBBox = new BBox(
|
|
94
|
-
|
|
95
|
-
type === 'time' ? availableTimelineHeight : availableTimelineHeight - timelineHeight,
|
|
96
|
+
x,
|
|
97
|
+
y + (type === 'time' ? availableTimelineHeight : availableTimelineHeight - timelineHeight),
|
|
96
98
|
+width,
|
|
97
99
|
timelineHeight - axisHeight
|
|
98
100
|
);
|
|
@@ -210,8 +212,9 @@ export class Timebar extends Component<TimebarStyleProps> {
|
|
|
210
212
|
if (typeof time === 'number') return parseBySeries(time);
|
|
211
213
|
return formatTime(time, 'YYYY-MM-DD HH:mm:ss');
|
|
212
214
|
},
|
|
213
|
-
x,
|
|
214
|
-
|
|
215
|
+
transform: `translate(${x}, ${y})`,
|
|
216
|
+
// x,
|
|
217
|
+
// y,
|
|
215
218
|
zIndex: 1,
|
|
216
219
|
...userDefinedChartStyle,
|
|
217
220
|
};
|
|
@@ -237,8 +240,9 @@ export class Timebar extends Component<TimebarStyleProps> {
|
|
|
237
240
|
trackSize: height,
|
|
238
241
|
type: selectionType,
|
|
239
242
|
values: this.sliderValues,
|
|
240
|
-
x,
|
|
241
|
-
y,
|
|
243
|
+
// x,
|
|
244
|
+
// y,
|
|
245
|
+
transform: `translate(${x}, ${y})`,
|
|
242
246
|
zIndex: 1,
|
|
243
247
|
...userDefinedChartStyle,
|
|
244
248
|
};
|
package/src/ui/timebar/types.ts
CHANGED
|
@@ -8,6 +8,8 @@ import type { LinearAxisStyleProps } from '../axis/types';
|
|
|
8
8
|
export type Functions = 'reset' | 'speed' | 'backward' | 'playPause' | 'forward' | 'selectionType' | 'chartType';
|
|
9
9
|
export type ControllerStyleProps = GroupStyleProps &
|
|
10
10
|
PrefixObject<BaseStyleProps, 'background'> & {
|
|
11
|
+
x?: number;
|
|
12
|
+
y?: number;
|
|
11
13
|
width: number;
|
|
12
14
|
height: number;
|
|
13
15
|
padding?: SeriesAttr;
|
|
@@ -72,6 +74,8 @@ export type TimebarStyleProps = GroupStyleProps &
|
|
|
72
74
|
PrefixObject<Omit<LinearAxisStyleProps, 'type' | 'startPos' | 'endPos' | 'data'>, 'axis'> &
|
|
73
75
|
Pick<ControllerStyleProps, UnvarnishedControllerProps> &
|
|
74
76
|
PrefixObject<Omit<ControllerStyleProps, 'width' | 'onChange' | UnvarnishedControllerProps>, 'controller'> & {
|
|
77
|
+
x?: number;
|
|
78
|
+
y?: number;
|
|
75
79
|
/**
|
|
76
80
|
* 类型
|
|
77
81
|
* @description time 时间轴
|