@antv/component 2.1.0 → 2.1.1-alpha.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/utils.js +31 -37
- package/esm/animation/utils.js.map +1 -1
- package/esm/constant.js +1 -1
- package/esm/constant.js.map +1 -1
- package/esm/core/component.js +30 -43
- package/esm/core/component.js.map +1 -1
- package/esm/shapes/Text.js +13 -21
- package/esm/shapes/Text.js.map +1 -1
- package/esm/ui/axis/axis.js +25 -31
- package/esm/ui/axis/axis.js.map +1 -1
- package/esm/ui/axis/constant.js +11 -13
- package/esm/ui/axis/constant.js.map +1 -1
- package/esm/ui/axis/guides/grid.js +29 -34
- package/esm/ui/axis/guides/grid.js.map +1 -1
- package/esm/ui/axis/guides/labels.js +76 -83
- package/esm/ui/axis/guides/labels.js.map +1 -1
- package/esm/ui/axis/guides/line.js +74 -87
- package/esm/ui/axis/guides/line.js.map +1 -1
- package/esm/ui/axis/guides/ticks.js +31 -39
- package/esm/ui/axis/guides/ticks.js.map +1 -1
- package/esm/ui/axis/guides/title.js +33 -37
- package/esm/ui/axis/guides/title.js.map +1 -1
- package/esm/ui/axis/guides/utils.js +10 -12
- package/esm/ui/axis/guides/utils.js.map +1 -1
- package/esm/ui/axis/overlap/autoEllipsis.js +12 -19
- package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
- package/esm/ui/axis/overlap/autoHide.js +20 -24
- package/esm/ui/axis/overlap/autoHide.js.map +1 -1
- package/esm/ui/axis/overlap/autoRotate.js +11 -25
- package/esm/ui/axis/overlap/autoRotate.js.map +1 -1
- package/esm/ui/axis/overlap/autoWrap.js +11 -14
- package/esm/ui/axis/overlap/autoWrap.js.map +1 -1
- package/esm/ui/axis/overlap/index.js +7 -7
- package/esm/ui/axis/overlap/index.js.map +1 -1
- package/esm/ui/axis/utils/bounds.js +48 -75
- package/esm/ui/axis/utils/bounds.js.map +1 -1
- package/esm/ui/axis/utils/contain.js +14 -14
- package/esm/ui/axis/utils/contain.js.map +1 -1
- package/esm/ui/axis/utils/index.js +3 -7
- package/esm/ui/axis/utils/index.js.map +1 -1
- package/esm/ui/axis/utils/intersect.js +21 -33
- package/esm/ui/axis/utils/intersect.js.map +1 -1
- package/esm/ui/axis/utils/test.js +29 -41
- package/esm/ui/axis/utils/test.js.map +1 -1
- package/esm/ui/breadcrumb/index.js +64 -72
- package/esm/ui/breadcrumb/index.js.map +1 -1
- package/esm/ui/button/constant.js +3 -3
- package/esm/ui/button/constant.js.map +1 -1
- package/esm/ui/button/index.js +81 -97
- package/esm/ui/button/index.js.map +1 -1
- package/esm/ui/checkbox/constant.js +4 -4
- package/esm/ui/checkbox/constant.js.map +1 -1
- package/esm/ui/checkbox/index.js +23 -26
- package/esm/ui/checkbox/index.js.map +1 -1
- package/esm/ui/crosshair/base.js +29 -45
- package/esm/ui/crosshair/base.js.map +1 -1
- package/esm/ui/crosshair/circle.js +25 -34
- package/esm/ui/crosshair/circle.js.map +1 -1
- package/esm/ui/crosshair/constant.js +4 -4
- package/esm/ui/crosshair/constant.js.map +1 -1
- package/esm/ui/crosshair/line.js +55 -75
- package/esm/ui/crosshair/line.js.map +1 -1
- package/esm/ui/crosshair/polygon.js +54 -70
- package/esm/ui/crosshair/polygon.js.map +1 -1
- package/esm/ui/grid/index.js +73 -95
- package/esm/ui/grid/index.js.map +1 -1
- package/esm/ui/indicator/constant.js +2 -2
- package/esm/ui/indicator/constant.js.map +1 -1
- package/esm/ui/indicator/indicator.js +58 -63
- package/esm/ui/indicator/indicator.js.map +1 -1
- package/esm/ui/layout/layout.js +52 -66
- package/esm/ui/layout/layout.js.map +1 -1
- package/esm/ui/legend/base.js +12 -13
- package/esm/ui/legend/base.js.map +1 -1
- package/esm/ui/legend/category/item.js +122 -156
- package/esm/ui/legend/category/item.js.map +1 -1
- package/esm/ui/legend/category/items.js +158 -201
- package/esm/ui/legend/category/items.js.map +1 -1
- package/esm/ui/legend/category.js +46 -56
- package/esm/ui/legend/category.js.map +1 -1
- package/esm/ui/legend/constant.js +6 -6
- package/esm/ui/legend/constant.js.map +1 -1
- package/esm/ui/legend/continuous/handle.js +28 -33
- package/esm/ui/legend/continuous/handle.js.map +1 -1
- package/esm/ui/legend/continuous/ribbon.js +34 -38
- package/esm/ui/legend/continuous/ribbon.js.map +1 -1
- package/esm/ui/legend/continuous/utils.js +10 -11
- package/esm/ui/legend/continuous/utils.js.map +1 -1
- package/esm/ui/legend/continuous.js +417 -521
- package/esm/ui/legend/continuous.js.map +1 -1
- package/esm/ui/legend/utils.js +24 -31
- package/esm/ui/legend/utils.js.map +1 -1
- package/esm/ui/marker/index.js +38 -44
- package/esm/ui/marker/index.js.map +1 -1
- package/esm/ui/marker/symbol.js +24 -24
- package/esm/ui/marker/symbol.js.map +1 -1
- package/esm/ui/marker/utils.js +2 -2
- package/esm/ui/marker/utils.js.map +1 -1
- package/esm/ui/navigator/index.js +128 -159
- package/esm/ui/navigator/index.js.map +1 -1
- package/esm/ui/poptip/constant.js +67 -68
- package/esm/ui/poptip/constant.js.map +1 -1
- package/esm/ui/poptip/index.js +95 -111
- package/esm/ui/poptip/index.js.map +1 -1
- package/esm/ui/poptip/utils.js +8 -15
- package/esm/ui/poptip/utils.js.map +1 -1
- package/esm/ui/scrollbar/index.js +102 -132
- package/esm/ui/scrollbar/index.js.map +1 -1
- package/esm/ui/select/option.js +48 -58
- package/esm/ui/select/option.js.map +1 -1
- package/esm/ui/select/select.js +142 -164
- package/esm/ui/select/select.js.map +1 -1
- package/esm/ui/slider/constant.js +4 -4
- package/esm/ui/slider/constant.js.map +1 -1
- package/esm/ui/slider/handle.js +46 -54
- package/esm/ui/slider/handle.js.map +1 -1
- package/esm/ui/slider/index.js +280 -326
- package/esm/ui/slider/index.js.map +1 -1
- package/esm/ui/sparkline/columns.js +25 -34
- package/esm/ui/sparkline/columns.js.map +1 -1
- package/esm/ui/sparkline/index.js +145 -180
- package/esm/ui/sparkline/index.js.map +1 -1
- package/esm/ui/sparkline/lines.js +37 -50
- package/esm/ui/sparkline/lines.js.map +1 -1
- package/esm/ui/sparkline/path.js +36 -40
- package/esm/ui/sparkline/path.js.map +1 -1
- package/esm/ui/sparkline/utils.js +8 -9
- package/esm/ui/sparkline/utils.js.map +1 -1
- package/esm/ui/switch/constant.js +1 -1
- package/esm/ui/switch/constant.js.map +1 -1
- package/esm/ui/switch/index.js +44 -54
- package/esm/ui/switch/index.js.map +1 -1
- package/esm/ui/tag/index.js +29 -32
- package/esm/ui/tag/index.js.map +1 -1
- package/esm/ui/timebar/controller.js +69 -79
- package/esm/ui/timebar/controller.js.map +1 -1
- package/esm/ui/timebar/handle.js +62 -71
- package/esm/ui/timebar/handle.js.map +1 -1
- package/esm/ui/timebar/icons.js +308 -478
- package/esm/ui/timebar/icons.js.map +1 -1
- package/esm/ui/timebar/timebar.js +263 -318
- package/esm/ui/timebar/timebar.js.map +1 -1
- package/esm/ui/timebar/utils.js +7 -7
- package/esm/ui/timebar/utils.js.map +1 -1
- package/esm/ui/timeline/index.js +2 -6
- package/esm/ui/timeline/index.js.map +1 -1
- package/esm/ui/title/index.js +59 -64
- package/esm/ui/title/index.js.map +1 -1
- package/esm/ui/tooltip/constant.js +26 -30
- package/esm/ui/tooltip/constant.js.map +1 -1
- package/esm/ui/tooltip/index.js +109 -126
- package/esm/ui/tooltip/index.js.map +1 -1
- package/esm/util/bbox.js +24 -47
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/callback.js +1 -2
- package/esm/util/callback.js.map +1 -1
- package/esm/util/classnames.js +8 -10
- package/esm/util/classnames.js.map +1 -1
- package/esm/util/deep-assign.js +6 -14
- package/esm/util/deep-assign.js.map +1 -1
- package/esm/util/defined.js +1 -1
- package/esm/util/defined.js.map +1 -1
- package/esm/util/ellipsis.js +1 -2
- package/esm/util/ellipsis.js.map +1 -1
- package/esm/util/event.js +3 -3
- package/esm/util/event.js.map +1 -1
- package/esm/util/geometry/line-length.js +1 -4
- package/esm/util/geometry/line-length.js.map +1 -1
- package/esm/util/geometry/lines-intersection.js +5 -10
- package/esm/util/geometry/lines-intersection.js.map +1 -1
- package/esm/util/group-by.js +1 -1
- package/esm/util/group-by.js.map +1 -1
- package/esm/util/group.js +3 -3
- package/esm/util/group.js.map +1 -1
- package/esm/util/html.js +1 -1
- package/esm/util/html.js.map +1 -1
- package/esm/util/if-show.js +3 -5
- package/esm/util/if-show.js.map +1 -1
- package/esm/util/in-range.js +1 -3
- package/esm/util/in-range.js.map +1 -1
- package/esm/util/interpolate.js +12 -19
- package/esm/util/interpolate.js.map +1 -1
- package/esm/util/keyframe-interpolate.js +6 -7
- package/esm/util/keyframe-interpolate.js.map +1 -1
- package/esm/util/layout/executer.js +4 -4
- package/esm/util/layout/executer.js.map +1 -1
- package/esm/util/layout/flex/index.js +24 -26
- package/esm/util/layout/flex/index.js.map +1 -1
- package/esm/util/layout/grid/index.js +1 -1
- package/esm/util/layout/grid/index.js.map +1 -1
- package/esm/util/layout/utils/helper.js +7 -8
- package/esm/util/layout/utils/helper.js.map +1 -1
- package/esm/util/matrix.js +7 -8
- package/esm/util/matrix.js.map +1 -1
- package/esm/util/number.js +6 -7
- package/esm/util/number.js.map +1 -1
- package/esm/util/offscreen.js +9 -17
- package/esm/util/offscreen.js.map +1 -1
- package/esm/util/omit.js +3 -3
- package/esm/util/omit.js.map +1 -1
- package/esm/util/path.js +36 -41
- package/esm/util/path.js.map +1 -1
- package/esm/util/primitive.js +3 -3
- package/esm/util/primitive.js.map +1 -1
- package/esm/util/replace-children.js +3 -4
- package/esm/util/replace-children.js.map +1 -1
- package/esm/util/sampling.js +3 -3
- package/esm/util/sampling.js.map +1 -1
- package/esm/util/scale-to-pixel.js +4 -5
- package/esm/util/scale-to-pixel.js.map +1 -1
- package/esm/util/selection.js +142 -186
- package/esm/util/selection.js.map +1 -1
- package/esm/util/series.js +1 -1
- package/esm/util/series.js.map +1 -1
- package/esm/util/shape.js +15 -27
- package/esm/util/shape.js.map +1 -1
- package/esm/util/string.js +4 -5
- package/esm/util/string.js.map +1 -1
- package/esm/util/style.js +23 -29
- package/esm/util/style.js.map +1 -1
- package/esm/util/svg2marker.js +13 -16
- package/esm/util/svg2marker.js.map +1 -1
- package/esm/util/text.js +14 -14
- package/esm/util/text.js.map +1 -1
- package/esm/util/throttle.js +7 -13
- package/esm/util/throttle.js.map +1 -1
- package/esm/util/time.js +22 -24
- package/esm/util/time.js.map +1 -1
- package/esm/util/timer.js +5 -9
- package/esm/util/timer.js.map +1 -1
- package/esm/util/transform.js +5 -6
- package/esm/util/transform.js.map +1 -1
- package/esm/util/transpose.js +1 -1
- package/esm/util/transpose.js.map +1 -1
- package/esm/util/traverse.js +1 -1
- package/esm/util/traverse.js.map +1 -1
- package/esm/util/visibility.js +2 -2
- package/esm/util/visibility.js.map +1 -1
- package/esm/util/wrap.js +2 -4
- package/esm/util/wrap.js.map +1 -1
- package/lib/animation/fadeIn.js +1 -1
- package/lib/animation/fadeIn.js.map +1 -1
- package/lib/animation/fadeOut.js +1 -1
- package/lib/animation/fadeOut.js.map +1 -1
- package/lib/animation/index.js +1 -1
- package/lib/animation/utils.js +33 -39
- package/lib/animation/utils.js.map +1 -1
- package/lib/core/component.js +31 -43
- package/lib/core/component.js.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/shapes/Text.js +15 -22
- package/lib/shapes/Text.js.map +1 -1
- package/lib/shapes/index.js +1 -1
- package/lib/types/index.js +1 -1
- package/lib/ui/axis/axis.js +34 -39
- package/lib/ui/axis/axis.js.map +1 -1
- package/lib/ui/axis/constant.js +10 -12
- package/lib/ui/axis/constant.js.map +1 -1
- package/lib/ui/axis/guides/grid.js +35 -40
- package/lib/ui/axis/guides/grid.js.map +1 -1
- package/lib/ui/axis/guides/labels.js +82 -89
- package/lib/ui/axis/guides/labels.js.map +1 -1
- package/lib/ui/axis/guides/line.js +79 -92
- package/lib/ui/axis/guides/line.js.map +1 -1
- package/lib/ui/axis/guides/ticks.js +37 -45
- package/lib/ui/axis/guides/ticks.js.map +1 -1
- package/lib/ui/axis/guides/title.js +37 -41
- package/lib/ui/axis/guides/title.js.map +1 -1
- package/lib/ui/axis/guides/utils.js +12 -14
- package/lib/ui/axis/guides/utils.js.map +1 -1
- package/lib/ui/axis/overlap/autoEllipsis.js +15 -22
- package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
- package/lib/ui/axis/overlap/autoHide.js +23 -27
- package/lib/ui/axis/overlap/autoHide.js.map +1 -1
- package/lib/ui/axis/overlap/autoRotate.js +12 -26
- package/lib/ui/axis/overlap/autoRotate.js.map +1 -1
- package/lib/ui/axis/overlap/autoWrap.js +13 -16
- package/lib/ui/axis/overlap/autoWrap.js.map +1 -1
- package/lib/ui/axis/overlap/index.js +12 -12
- package/lib/ui/axis/overlap/index.js.map +1 -1
- package/lib/ui/axis/utils/bounds.js +49 -75
- package/lib/ui/axis/utils/bounds.js.map +1 -1
- package/lib/ui/axis/utils/contain.js +15 -15
- package/lib/ui/axis/utils/contain.js.map +1 -1
- package/lib/ui/axis/utils/index.js +4 -8
- package/lib/ui/axis/utils/index.js.map +1 -1
- package/lib/ui/axis/utils/intersect.js +22 -34
- package/lib/ui/axis/utils/intersect.js.map +1 -1
- package/lib/ui/axis/utils/test.js +35 -47
- package/lib/ui/axis/utils/test.js.map +1 -1
- package/lib/ui/breadcrumb/index.js +70 -77
- package/lib/ui/breadcrumb/index.js.map +1 -1
- package/lib/ui/button/index.js +86 -101
- package/lib/ui/button/index.js.map +1 -1
- package/lib/ui/checkbox/constant.js +2 -2
- package/lib/ui/checkbox/constant.js.map +1 -1
- package/lib/ui/checkbox/index.js +26 -28
- package/lib/ui/checkbox/index.js.map +1 -1
- package/lib/ui/crosshair/base.js +33 -48
- package/lib/ui/crosshair/base.js.map +1 -1
- package/lib/ui/crosshair/circle.js +29 -37
- package/lib/ui/crosshair/circle.js.map +1 -1
- package/lib/ui/crosshair/constant.js +1 -1
- package/lib/ui/crosshair/constant.js.map +1 -1
- package/lib/ui/crosshair/index.js +1 -1
- package/lib/ui/crosshair/line.js +58 -77
- package/lib/ui/crosshair/line.js.map +1 -1
- package/lib/ui/crosshair/polygon.js +57 -72
- package/lib/ui/crosshair/polygon.js.map +1 -1
- package/lib/ui/grid/index.js +76 -97
- package/lib/ui/grid/index.js.map +1 -1
- package/lib/ui/indicator/constant.js +1 -1
- package/lib/ui/indicator/constant.js.map +1 -1
- package/lib/ui/indicator/index.js +1 -1
- package/lib/ui/indicator/indicator.js +63 -67
- package/lib/ui/indicator/indicator.js.map +1 -1
- package/lib/ui/layout/layout.js +57 -70
- package/lib/ui/layout/layout.js.map +1 -1
- package/lib/ui/legend/base.js +14 -15
- package/lib/ui/legend/base.js.map +1 -1
- package/lib/ui/legend/category/item.js +126 -159
- package/lib/ui/legend/category/item.js.map +1 -1
- package/lib/ui/legend/category/items.js +166 -208
- package/lib/ui/legend/category/items.js.map +1 -1
- package/lib/ui/legend/category.js +51 -60
- package/lib/ui/legend/category.js.map +1 -1
- package/lib/ui/legend/constant.js +2 -2
- package/lib/ui/legend/constant.js.map +1 -1
- package/lib/ui/legend/continuous/handle.js +31 -35
- package/lib/ui/legend/continuous/handle.js.map +1 -1
- package/lib/ui/legend/continuous/ribbon.js +40 -43
- package/lib/ui/legend/continuous/ribbon.js.map +1 -1
- package/lib/ui/legend/continuous/utils.js +10 -11
- package/lib/ui/legend/continuous/utils.js.map +1 -1
- package/lib/ui/legend/continuous.js +432 -535
- package/lib/ui/legend/continuous.js.map +1 -1
- package/lib/ui/legend/index.js +2 -2
- package/lib/ui/legend/index.js.map +1 -1
- package/lib/ui/legend/utils.js +25 -32
- package/lib/ui/legend/utils.js.map +1 -1
- package/lib/ui/marker/index.js +43 -48
- package/lib/ui/marker/index.js.map +1 -1
- package/lib/ui/marker/symbol.js +22 -22
- package/lib/ui/marker/symbol.js.map +1 -1
- package/lib/ui/marker/utils.js +3 -3
- package/lib/ui/marker/utils.js.map +1 -1
- package/lib/ui/navigator/index.js +135 -165
- package/lib/ui/navigator/index.js.map +1 -1
- package/lib/ui/poptip/constant.js +65 -66
- package/lib/ui/poptip/constant.js.map +1 -1
- package/lib/ui/poptip/index.js +100 -115
- package/lib/ui/poptip/index.js.map +1 -1
- package/lib/ui/poptip/utils.js +8 -15
- package/lib/ui/poptip/utils.js.map +1 -1
- package/lib/ui/scrollbar/index.js +107 -136
- package/lib/ui/scrollbar/index.js.map +1 -1
- package/lib/ui/select/option.js +52 -61
- package/lib/ui/select/option.js.map +1 -1
- package/lib/ui/select/select.js +148 -169
- package/lib/ui/select/select.js.map +1 -1
- package/lib/ui/slider/constant.js +1 -1
- package/lib/ui/slider/constant.js.map +1 -1
- package/lib/ui/slider/handle.js +49 -56
- package/lib/ui/slider/handle.js.map +1 -1
- package/lib/ui/slider/index.js +289 -334
- package/lib/ui/slider/index.js.map +1 -1
- package/lib/ui/sparkline/columns.js +28 -36
- package/lib/ui/sparkline/columns.js.map +1 -1
- package/lib/ui/sparkline/index.js +153 -187
- package/lib/ui/sparkline/index.js.map +1 -1
- package/lib/ui/sparkline/lines.js +40 -52
- package/lib/ui/sparkline/lines.js.map +1 -1
- package/lib/ui/sparkline/path.js +38 -42
- package/lib/ui/sparkline/path.js.map +1 -1
- package/lib/ui/sparkline/utils.js +9 -10
- package/lib/ui/sparkline/utils.js.map +1 -1
- package/lib/ui/switch/index.js +49 -58
- package/lib/ui/switch/index.js.map +1 -1
- package/lib/ui/tag/index.js +34 -36
- package/lib/ui/tag/index.js.map +1 -1
- package/lib/ui/timebar/controller.js +73 -82
- package/lib/ui/timebar/controller.js.map +1 -1
- package/lib/ui/timebar/handle.js +67 -74
- package/lib/ui/timebar/handle.js.map +1 -1
- package/lib/ui/timebar/icons.js +312 -466
- package/lib/ui/timebar/icons.js.map +1 -1
- package/lib/ui/timebar/timebar.js +272 -326
- package/lib/ui/timebar/timebar.js.map +1 -1
- package/lib/ui/timebar/utils.js +8 -8
- package/lib/ui/timebar/utils.js.map +1 -1
- package/lib/ui/timeline/index.js +2 -5
- package/lib/ui/timeline/index.js.map +1 -1
- package/lib/ui/title/index.js +61 -65
- package/lib/ui/title/index.js.map +1 -1
- package/lib/ui/tooltip/constant.js +26 -30
- package/lib/ui/tooltip/constant.js.map +1 -1
- package/lib/ui/tooltip/index.js +113 -129
- package/lib/ui/tooltip/index.js.map +1 -1
- package/lib/util/bbox.js +24 -46
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/callback.js +2 -3
- package/lib/util/callback.js.map +1 -1
- package/lib/util/classnames.js +8 -10
- package/lib/util/classnames.js.map +1 -1
- package/lib/util/deep-assign.js +7 -15
- package/lib/util/deep-assign.js.map +1 -1
- package/lib/util/defined.js +1 -1
- package/lib/util/defined.js.map +1 -1
- package/lib/util/ellipsis.js +2 -3
- package/lib/util/ellipsis.js.map +1 -1
- package/lib/util/event.js +3 -3
- package/lib/util/event.js.map +1 -1
- package/lib/util/extend-display-object.js +2 -2
- package/lib/util/extend-display-object.js.map +1 -1
- package/lib/util/geometry/index.js +1 -1
- package/lib/util/geometry/line-length.js +1 -4
- package/lib/util/geometry/line-length.js.map +1 -1
- package/lib/util/geometry/lines-intersection.js +5 -10
- package/lib/util/geometry/lines-intersection.js.map +1 -1
- package/lib/util/group-by.js +1 -1
- package/lib/util/group-by.js.map +1 -1
- package/lib/util/group.js +3 -3
- package/lib/util/group.js.map +1 -1
- package/lib/util/html.js +1 -1
- package/lib/util/html.js.map +1 -1
- package/lib/util/if-show.js +3 -5
- package/lib/util/if-show.js.map +1 -1
- package/lib/util/in-range.js +1 -3
- package/lib/util/in-range.js.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/interpolate.js +12 -19
- package/lib/util/interpolate.js.map +1 -1
- package/lib/util/keyframe-interpolate.js +7 -8
- package/lib/util/keyframe-interpolate.js.map +1 -1
- package/lib/util/layout/executer.js +6 -6
- package/lib/util/layout/executer.js.map +1 -1
- package/lib/util/layout/flex/index.js +26 -28
- package/lib/util/layout/flex/index.js.map +1 -1
- package/lib/util/layout/grid/index.js +1 -1
- package/lib/util/layout/grid/index.js.map +1 -1
- package/lib/util/layout/index.js +1 -1
- package/lib/util/layout/utils/helper.js +8 -9
- package/lib/util/layout/utils/helper.js.map +1 -1
- package/lib/util/matrix.js +7 -8
- package/lib/util/matrix.js.map +1 -1
- package/lib/util/number.js +6 -7
- package/lib/util/number.js.map +1 -1
- package/lib/util/offscreen.js +12 -20
- package/lib/util/offscreen.js.map +1 -1
- package/lib/util/omit.js +3 -3
- package/lib/util/omit.js.map +1 -1
- package/lib/util/path.js +37 -42
- package/lib/util/path.js.map +1 -1
- package/lib/util/primitive.js +2 -2
- package/lib/util/primitive.js.map +1 -1
- package/lib/util/replace-children.js +3 -4
- package/lib/util/replace-children.js.map +1 -1
- package/lib/util/sampling.js +3 -3
- package/lib/util/sampling.js.map +1 -1
- package/lib/util/scale-to-pixel.js +4 -5
- package/lib/util/scale-to-pixel.js.map +1 -1
- package/lib/util/selection.js +144 -187
- package/lib/util/selection.js.map +1 -1
- package/lib/util/series.js +2 -2
- package/lib/util/series.js.map +1 -1
- package/lib/util/shape.js +16 -28
- 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 +24 -30
- package/lib/util/style.js.map +1 -1
- package/lib/util/svg2marker.js +15 -17
- package/lib/util/svg2marker.js.map +1 -1
- package/lib/util/text.js +16 -16
- package/lib/util/text.js.map +1 -1
- package/lib/util/throttle.js +7 -13
- package/lib/util/throttle.js.map +1 -1
- package/lib/util/time.js +22 -24
- package/lib/util/time.js.map +1 -1
- package/lib/util/timer.js +5 -9
- package/lib/util/timer.js.map +1 -1
- package/lib/util/transform.js +5 -6
- package/lib/util/transform.js.map +1 -1
- package/lib/util/transpose.js +1 -1
- package/lib/util/transpose.js.map +1 -1
- package/lib/util/traverse.js +1 -1
- package/lib/util/traverse.js.map +1 -1
- package/lib/util/visibility.js +3 -3
- package/lib/util/visibility.js.map +1 -1
- package/lib/util/wrap.js +3 -5
- package/lib/util/wrap.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
2
|
import { clamp } from '@antv/util';
|
|
3
3
|
import { Component } from '../../core';
|
|
4
4
|
import { Line } from '../../shapes';
|
|
@@ -8,254 +8,179 @@ import { Slider } from '../slider';
|
|
|
8
8
|
import { Controller } from './controller';
|
|
9
9
|
import { ChartModeHandle, TimeModeHandle } from './handle';
|
|
10
10
|
import { labelFormatter, parseBySeries } from './utils';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
style: {
|
|
21
|
-
onChange: function (values) {
|
|
22
|
-
_this.handleSliderChange(values);
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
}));
|
|
26
|
-
_this.controller = _this.appendChild(new Controller({}));
|
|
27
|
-
_this.states = {};
|
|
28
|
-
_this.handleSliderChange = function (values) {
|
|
29
|
-
var prevValues = (function () {
|
|
30
|
-
var val = _this.states.values;
|
|
31
|
-
if (Array.isArray(val))
|
|
32
|
-
return __spreadArray([], __read(val), false);
|
|
33
|
-
return val;
|
|
34
|
-
})();
|
|
35
|
-
_this.setBySliderValues(values);
|
|
36
|
-
_this.dispatchOnChange(prevValues);
|
|
11
|
+
export class Timebar extends Component {
|
|
12
|
+
get data() {
|
|
13
|
+
const { data } = this.attributes;
|
|
14
|
+
const compareFn = (a, b) => {
|
|
15
|
+
if (a.time < b.time)
|
|
16
|
+
return -1;
|
|
17
|
+
if (a.time > b.time)
|
|
18
|
+
return 1;
|
|
19
|
+
return 0;
|
|
37
20
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
get: function () {
|
|
61
|
-
var _a = this.attributes, x = _a.x, y = _a.y, width = _a.width, height = _a.height, type = _a.type, controllerHeight = _a.controllerHeight;
|
|
62
|
-
var availableTimelineHeight = clamp(+height - controllerHeight, 0, +height);
|
|
63
|
-
var controllerBBox = new BBox(x, y + +height - controllerHeight, +width, controllerHeight);
|
|
64
|
-
// chart 模式下可用
|
|
65
|
-
var axisBBox;
|
|
66
|
-
var axisHeight = 0;
|
|
67
|
-
if (type === 'chart') {
|
|
68
|
-
// axis 默认分配高度为 35
|
|
69
|
-
axisHeight = 35;
|
|
70
|
-
axisBBox = new BBox(x, y + availableTimelineHeight - axisHeight, +width, axisHeight);
|
|
71
|
-
}
|
|
72
|
-
else
|
|
73
|
-
axisBBox = new BBox();
|
|
74
|
-
var timelineHeight = type === 'time' ? 10 : availableTimelineHeight;
|
|
75
|
-
var timelineBBox = new BBox(x, y + (type === 'time' ? availableTimelineHeight : availableTimelineHeight - timelineHeight), +width, timelineHeight - axisHeight);
|
|
76
|
-
return { axisBBox: axisBBox, controllerBBox: controllerBBox, timelineBBox: timelineBBox };
|
|
77
|
-
},
|
|
78
|
-
enumerable: false,
|
|
79
|
-
configurable: true
|
|
80
|
-
});
|
|
81
|
-
Timebar.prototype.setBySliderValues = function (val) {
|
|
21
|
+
return data.sort(compareFn);
|
|
22
|
+
}
|
|
23
|
+
/** 计算空间分配 */
|
|
24
|
+
get space() {
|
|
25
|
+
const { x, y, width, height, type, controllerHeight } = this.attributes;
|
|
26
|
+
const availableTimelineHeight = clamp(+height - controllerHeight, 0, +height);
|
|
27
|
+
const controllerBBox = new BBox(x, y + +height - controllerHeight, +width, controllerHeight);
|
|
28
|
+
// chart 模式下可用
|
|
29
|
+
let axisBBox;
|
|
30
|
+
let axisHeight = 0;
|
|
31
|
+
if (type === 'chart') {
|
|
32
|
+
// axis 默认分配高度为 35
|
|
33
|
+
axisHeight = 35;
|
|
34
|
+
axisBBox = new BBox(x, y + availableTimelineHeight - axisHeight, +width, axisHeight);
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
axisBBox = new BBox();
|
|
38
|
+
const timelineHeight = type === 'time' ? 10 : availableTimelineHeight;
|
|
39
|
+
const timelineBBox = new BBox(x, y + (type === 'time' ? availableTimelineHeight : availableTimelineHeight - timelineHeight), +width, timelineHeight - axisHeight);
|
|
40
|
+
return { axisBBox, controllerBBox, timelineBBox };
|
|
41
|
+
}
|
|
42
|
+
setBySliderValues(val) {
|
|
82
43
|
var _a, _b;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
44
|
+
const { data } = this;
|
|
45
|
+
const [startRatio, endRatio] = Array.isArray(val) ? val : [0, val];
|
|
46
|
+
const length = data.length;
|
|
47
|
+
const startDatum = data[Math.floor(startRatio * length)];
|
|
48
|
+
const endDatum = data[Math.ceil(endRatio * length) - (Array.isArray(val) ? 0 : 1)];
|
|
88
49
|
// 如果 endDatum 不存在,则其已经比最大的时间范围更大
|
|
89
50
|
this.states.values = [(_a = startDatum === null || startDatum === void 0 ? void 0 : startDatum.time) !== null && _a !== void 0 ? _a : data[0].time, (_b = endDatum === null || endDatum === void 0 ? void 0 : endDatum.time) !== null && _b !== void 0 ? _b : Infinity];
|
|
90
|
-
}
|
|
91
|
-
|
|
51
|
+
}
|
|
52
|
+
setByTimebarValues(val) {
|
|
92
53
|
var _a, _b, _c;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return time === start;
|
|
98
|
-
});
|
|
99
|
-
var endDatum = data.find(function (_a) {
|
|
100
|
-
var time = _a.time;
|
|
101
|
-
return time === end;
|
|
102
|
-
});
|
|
54
|
+
const { data } = this;
|
|
55
|
+
const [start, end] = Array.isArray(val) ? val : [undefined, val];
|
|
56
|
+
const startDatum = data.find(({ time }) => time === start);
|
|
57
|
+
const endDatum = data.find(({ time }) => time === end);
|
|
103
58
|
this.states.values = [(_a = startDatum === null || startDatum === void 0 ? void 0 : startDatum.time) !== null && _a !== void 0 ? _a : (_b = data[0]) === null || _b === void 0 ? void 0 : _b.time, (_c = endDatum === null || endDatum === void 0 ? void 0 : endDatum.time) !== null && _c !== void 0 ? _c : Infinity];
|
|
104
|
-
}
|
|
105
|
-
|
|
59
|
+
}
|
|
60
|
+
setByIndex(index) {
|
|
106
61
|
var _a, _b, _c, _d;
|
|
107
|
-
|
|
108
|
-
|
|
62
|
+
const { data } = this;
|
|
63
|
+
const [startIndex, endIndex] = index;
|
|
109
64
|
this.states.values = [(_b = (_a = data[startIndex]) === null || _a === void 0 ? void 0 : _a.time) !== null && _b !== void 0 ? _b : data[0].time, (_d = (_c = this.data[endIndex]) === null || _c === void 0 ? void 0 : _c.time) !== null && _d !== void 0 ? _d : Infinity];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var time = _a.time;
|
|
124
|
-
return time === start;
|
|
125
|
-
});
|
|
126
|
-
if (isValue)
|
|
127
|
-
return 0;
|
|
128
|
-
if (startDatumIndex > -1)
|
|
129
|
-
return startDatumIndex / length;
|
|
130
|
-
// value 模式下默认取 0
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 获取 timebar 的 values
|
|
68
|
+
*/
|
|
69
|
+
get sliderValues() {
|
|
70
|
+
const { values, selectionType } = this.states;
|
|
71
|
+
const [start, end] = Array.isArray(values) ? values : [undefined, values];
|
|
72
|
+
const { data } = this;
|
|
73
|
+
const length = data.length;
|
|
74
|
+
const isValue = selectionType === 'value';
|
|
75
|
+
const getStartValue = () => {
|
|
76
|
+
const startDatumIndex = data.findIndex(({ time }) => time === start);
|
|
77
|
+
if (isValue)
|
|
131
78
|
return 0;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
if (endDatumIndex > -1)
|
|
141
|
-
return endDatumIndex / length;
|
|
142
|
-
// range 模式下默认取 1,value 模式下默认取 0.5
|
|
143
|
-
if (isValue)
|
|
144
|
-
return 0.5;
|
|
79
|
+
if (startDatumIndex > -1)
|
|
80
|
+
return startDatumIndex / length;
|
|
81
|
+
// value 模式下默认取 0
|
|
82
|
+
return 0;
|
|
83
|
+
};
|
|
84
|
+
const getEndValue = () => {
|
|
85
|
+
if (end === Infinity)
|
|
145
86
|
return 1;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
87
|
+
const endDatumIndex = data.findIndex(({ time }) => time === end);
|
|
88
|
+
if (endDatumIndex > -1)
|
|
89
|
+
return endDatumIndex / length;
|
|
90
|
+
// range 模式下默认取 1,value 模式下默认取 0.5
|
|
91
|
+
if (isValue)
|
|
92
|
+
return 0.5;
|
|
93
|
+
return 1;
|
|
94
|
+
};
|
|
95
|
+
return [getStartValue(), getEndValue()];
|
|
96
|
+
}
|
|
97
|
+
get values() {
|
|
98
|
+
const { values, selectionType } = this.states;
|
|
99
|
+
const [start, end] = Array.isArray(values) ? values : [this.data[0].time, values];
|
|
100
|
+
if (selectionType === 'value')
|
|
101
|
+
return end;
|
|
102
|
+
return [start, end];
|
|
103
|
+
}
|
|
104
|
+
getDatumByRatio(ratio) {
|
|
105
|
+
const { data } = this;
|
|
106
|
+
const length = data.length;
|
|
107
|
+
const index = Math.floor(ratio * (length - 1));
|
|
167
108
|
return data[index];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
var _this = this;
|
|
184
|
-
var x = bbox.x, y = bbox.y, width = bbox.width, height = bbox.height;
|
|
185
|
-
var _a = this.states, selectionType = _a.selectionType, chartType = _a.chartType;
|
|
186
|
-
var data = this.data;
|
|
187
|
-
var _b = this.attributes, type = _b.type, userDefinedLabelFormatter = _b.labelFormatter;
|
|
188
|
-
var _c = subStyleProps(this.attributes, 'chart'), ignoreType = _c.type, userDefinedChartStyle = __rest(_c, ["type"]);
|
|
189
|
-
var isRange = selectionType === 'range';
|
|
109
|
+
}
|
|
110
|
+
get chartHandleIconShape() {
|
|
111
|
+
const { selectionType } = this.states;
|
|
112
|
+
const { timelineBBox: { height }, } = this.space;
|
|
113
|
+
if (selectionType === 'range')
|
|
114
|
+
return (type) => new ChartModeHandle({ style: { type, height, iconSize: height / 6 } });
|
|
115
|
+
return () => new Line({ style: { x1: 0, y1: -height / 2, x2: 0, y2: height / 2, lineWidth: 2, stroke: '#c8c8c8' } });
|
|
116
|
+
}
|
|
117
|
+
getChartStyle(bbox) {
|
|
118
|
+
const { x, y, width, height } = bbox;
|
|
119
|
+
const { selectionType, chartType } = this.states;
|
|
120
|
+
const { data } = this;
|
|
121
|
+
const { type, labelFormatter: userDefinedLabelFormatter } = this.attributes;
|
|
122
|
+
const _a = subStyleProps(this.attributes, 'chart'), { type: ignoreType } = _a, userDefinedChartStyle = __rest(_a, ["type"]);
|
|
123
|
+
const isRange = selectionType === 'range';
|
|
190
124
|
if (type === 'time') {
|
|
191
|
-
return
|
|
125
|
+
return Object.assign({ handleIconShape: () => new TimeModeHandle({}), selectionFill: '#2e7ff8', selectionFillOpacity: 1, showLabelOnInteraction: true, handleLabelDy: isRange ? -15 : 0, autoFitLabel: isRange, handleSpacing: isRange ? -15 : 0, trackFill: '#edeeef', trackLength: width, trackOpacity: 0.5, trackRadius: height / 2, trackSize: height / 2, type: selectionType, values: this.sliderValues, formatter: (value) => {
|
|
192
126
|
if (userDefinedLabelFormatter)
|
|
193
127
|
return userDefinedLabelFormatter(value);
|
|
194
|
-
|
|
128
|
+
const time = this.getDatumByRatio(value).time;
|
|
195
129
|
if (typeof time === 'number')
|
|
196
130
|
return parseBySeries(time);
|
|
197
131
|
return formatTime(time, 'YYYY-MM-DD HH:mm:ss');
|
|
198
|
-
}, transform:
|
|
132
|
+
}, transform: `translate(${x}, ${y})`,
|
|
199
133
|
// x,
|
|
200
134
|
// y,
|
|
201
135
|
zIndex: 1 }, userDefinedChartStyle);
|
|
202
136
|
}
|
|
203
137
|
// type === 'chart'
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return value;
|
|
208
|
-
});
|
|
209
|
-
return __assign({ handleIconOffset: handleIconOffset, handleIconShape: this.chartHandleIconShape, selectionFill: '#fff', selectionFillOpacity: 0.5, selectionType: 'invert', sparklineSpacing: 0.1, sparklineColumnLineWidth: 0, sparklineColor: '#d4e5fd', sparklineAreaOpacity: 1, sparklineAreaLineWidth: 0, sparklineData: sparklineData, sparklineType: chartType, sparklineScale: 0.8, trackLength: width, trackSize: height, type: selectionType, values: this.sliderValues,
|
|
138
|
+
const handleIconOffset = selectionType === 'range' ? 5 : 0;
|
|
139
|
+
const sparklineData = data.map(({ value }) => value);
|
|
140
|
+
return Object.assign({ handleIconOffset, handleIconShape: this.chartHandleIconShape, selectionFill: '#fff', selectionFillOpacity: 0.5, selectionType: 'invert', sparklineSpacing: 0.1, sparklineColumnLineWidth: 0, sparklineColor: '#d4e5fd', sparklineAreaOpacity: 1, sparklineAreaLineWidth: 0, sparklineData, sparklineType: chartType, sparklineScale: 0.8, trackLength: width, trackSize: height, type: selectionType, values: this.sliderValues,
|
|
210
141
|
// x,
|
|
211
142
|
// y,
|
|
212
|
-
transform:
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (bbox === void 0) { bbox = this.space.timelineBBox; }
|
|
143
|
+
transform: `translate(${x}, ${y})`, zIndex: 1 }, userDefinedChartStyle);
|
|
144
|
+
}
|
|
145
|
+
renderChart(bbox = this.space.timelineBBox) {
|
|
216
146
|
this.timeline.update(this.getChartStyle(bbox));
|
|
217
|
-
}
|
|
218
|
-
|
|
147
|
+
}
|
|
148
|
+
updateSelection() {
|
|
219
149
|
this.timeline.setValues(this.sliderValues, true);
|
|
220
150
|
this.handleSliderChange(this.sliderValues);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
151
|
+
}
|
|
152
|
+
getAxisStyle(bbox) {
|
|
153
|
+
const { data } = this;
|
|
154
|
+
const { interval, labelFormatter: userDefinedLabelFormatter } = this.attributes;
|
|
155
|
+
const userDefinedAxisStyle = subStyleProps(this.attributes, 'axis');
|
|
156
|
+
const { x, y, width } = bbox;
|
|
227
157
|
// 需要补一个刻度
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
var style = __assign({ startPos: [x, y], endPos: [x + width, y], data: axisData,
|
|
158
|
+
const axisData = [...data, { time: 0 }].map(({ time }, index, arr) => ({
|
|
159
|
+
label: `${time}`,
|
|
160
|
+
value: index / (arr.length - 1),
|
|
161
|
+
time,
|
|
162
|
+
}));
|
|
163
|
+
const style = Object.assign({ startPos: [x, y], endPos: [x + width, y], data: axisData,
|
|
237
164
|
// hide last label
|
|
238
|
-
labelFilter:
|
|
239
|
-
var time = _a.time;
|
|
240
|
-
return userDefinedLabelFormatter ? userDefinedLabelFormatter(time) : labelFormatter(time, interval);
|
|
241
|
-
} }, userDefinedAxisStyle);
|
|
165
|
+
labelFilter: (_datum, index) => index < axisData.length - 1, labelFormatter: ({ time }) => userDefinedLabelFormatter ? userDefinedLabelFormatter(time) : labelFormatter(time, interval) }, userDefinedAxisStyle);
|
|
242
166
|
return style;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
var type = this.attributes.type;
|
|
167
|
+
}
|
|
168
|
+
renderAxis(bbox = this.space.axisBBox) {
|
|
169
|
+
const { type } = this.attributes;
|
|
247
170
|
if (type !== 'chart')
|
|
248
171
|
return;
|
|
249
172
|
this.axis.update(this.getAxisStyle(bbox));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
173
|
+
}
|
|
174
|
+
renderController(bbox = this.space.controllerBBox) {
|
|
175
|
+
const { type } = this.attributes;
|
|
176
|
+
const { state, speed, selectionType, chartType } = this.states;
|
|
177
|
+
const userDefinedControllerStyle = subStyleProps(this.attributes, 'controller');
|
|
178
|
+
const that = this;
|
|
179
|
+
const style = Object.assign(Object.assign(Object.assign({}, bbox), { iconSize: 20, speed,
|
|
180
|
+
state,
|
|
181
|
+
selectionType,
|
|
182
|
+
chartType,
|
|
183
|
+
onChange(type, { value }) {
|
|
259
184
|
switch (type) {
|
|
260
185
|
case 'reset':
|
|
261
186
|
that.internalReset();
|
|
@@ -289,15 +214,15 @@ var Timebar = /** @class */ (function (_super) {
|
|
|
289
214
|
style.functions = [['reset', 'speed'], ['backward', 'playPause', 'forward'], ['selectionType']];
|
|
290
215
|
}
|
|
291
216
|
this.controller.update(style);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
217
|
+
}
|
|
218
|
+
dispatchOnChange(prevValues) {
|
|
219
|
+
const { data } = this;
|
|
220
|
+
const { onChange } = this.attributes;
|
|
221
|
+
const { values, selectionType } = this.states;
|
|
222
|
+
const [start, end] = values;
|
|
223
|
+
const endTime = end === Infinity ? data.at(-1).time : end;
|
|
224
|
+
const newValues = selectionType === 'range' ? [start, endTime] : endTime;
|
|
225
|
+
const isEqual = (val1, val2) => {
|
|
301
226
|
if (Array.isArray(val1)) {
|
|
302
227
|
if (!Array.isArray(val2))
|
|
303
228
|
return false;
|
|
@@ -317,10 +242,10 @@ var Timebar = /** @class */ (function (_super) {
|
|
|
317
242
|
if (!prevValues || !isEqual(prevValues, newValues)) {
|
|
318
243
|
onChange === null || onChange === void 0 ? void 0 : onChange(selectionType === 'range' ? [start, endTime] : endTime);
|
|
319
244
|
}
|
|
320
|
-
}
|
|
321
|
-
|
|
245
|
+
}
|
|
246
|
+
internalReset(preventEvent) {
|
|
322
247
|
var _a, _b;
|
|
323
|
-
|
|
248
|
+
const { selectionType } = this.states;
|
|
324
249
|
this.internalPause();
|
|
325
250
|
this.setBySliderValues(selectionType === 'range' ? [0, 1] : [0, 0]);
|
|
326
251
|
this.renderController();
|
|
@@ -329,27 +254,21 @@ var Timebar = /** @class */ (function (_super) {
|
|
|
329
254
|
(_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onReset) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
330
255
|
this.dispatchOnChange();
|
|
331
256
|
}
|
|
332
|
-
}
|
|
333
|
-
|
|
257
|
+
}
|
|
258
|
+
reset() {
|
|
334
259
|
this.internalReset();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
return time === startTime;
|
|
344
|
-
});
|
|
345
|
-
var endIndex = data.findIndex(function (_a) {
|
|
346
|
-
var time = _a.time;
|
|
347
|
-
return time === endTime;
|
|
348
|
-
});
|
|
260
|
+
}
|
|
261
|
+
moveSelection(direction, preventEvent) {
|
|
262
|
+
const { data } = this;
|
|
263
|
+
const length = data.length;
|
|
264
|
+
const { values, selectionType, playMode } = this.states;
|
|
265
|
+
const [startTime, endTime] = values;
|
|
266
|
+
const startIndex = data.findIndex(({ time }) => time === startTime);
|
|
267
|
+
let endIndex = data.findIndex(({ time }) => time === endTime);
|
|
349
268
|
if (endIndex === -1)
|
|
350
269
|
endIndex = length;
|
|
351
|
-
|
|
352
|
-
|
|
270
|
+
const diff = direction === 'backward' ? -1 : 1;
|
|
271
|
+
let currentIndexes;
|
|
353
272
|
if (selectionType === 'range') {
|
|
354
273
|
// end 后移一个时间间隔
|
|
355
274
|
if (playMode === 'acc') {
|
|
@@ -366,11 +285,11 @@ var Timebar = /** @class */ (function (_super) {
|
|
|
366
285
|
// end 后移一个时间间隔
|
|
367
286
|
else
|
|
368
287
|
currentIndexes = [startIndex, endIndex + diff];
|
|
369
|
-
|
|
288
|
+
const normalizeIndexes = (indexes) => {
|
|
370
289
|
// 先进行排序
|
|
371
|
-
|
|
290
|
+
const [start, end] = indexes.sort((a, b) => a - b);
|
|
372
291
|
// 保证 index 在 [0, length]
|
|
373
|
-
|
|
292
|
+
const clampIndex = (index) => clamp(index, 0, length);
|
|
374
293
|
// 如果 end 超出最大值
|
|
375
294
|
if (end > length) {
|
|
376
295
|
// value 模式下,重置到 0
|
|
@@ -390,126 +309,152 @@ var Timebar = /** @class */ (function (_super) {
|
|
|
390
309
|
}
|
|
391
310
|
return [clampIndex(start), clampIndex(end)];
|
|
392
311
|
};
|
|
393
|
-
|
|
312
|
+
const normalizedIndexes = normalizeIndexes(currentIndexes);
|
|
394
313
|
this.setByIndex(normalizedIndexes);
|
|
395
314
|
this.updateSelection();
|
|
396
315
|
return normalizedIndexes;
|
|
397
|
-
}
|
|
398
|
-
|
|
316
|
+
}
|
|
317
|
+
internalBackward(preventEvent) {
|
|
399
318
|
var _a, _b;
|
|
400
|
-
|
|
319
|
+
const indexes = this.moveSelection('backward', preventEvent);
|
|
401
320
|
if (!preventEvent) {
|
|
402
321
|
(_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onBackward) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
403
322
|
this.dispatchOnChange();
|
|
404
323
|
}
|
|
405
324
|
return indexes;
|
|
406
|
-
}
|
|
407
|
-
|
|
325
|
+
}
|
|
326
|
+
backward() {
|
|
408
327
|
this.internalBackward();
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
var _this = this;
|
|
328
|
+
}
|
|
329
|
+
internalPlay(preventEvent) {
|
|
412
330
|
var _a, _b;
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
this.playInterval = window.setInterval(
|
|
417
|
-
|
|
331
|
+
const { data } = this;
|
|
332
|
+
const { loop } = this.attributes;
|
|
333
|
+
const { speed = 1 } = this.states;
|
|
334
|
+
this.playInterval = window.setInterval(() => {
|
|
335
|
+
const indexes = this.internalForward();
|
|
418
336
|
// 如果不是循环播放,则播放到最后一个值时暂停
|
|
419
337
|
if (indexes[1] === data.length && !loop) {
|
|
420
338
|
// 这里需要抛出暂停事件
|
|
421
|
-
|
|
422
|
-
|
|
339
|
+
this.internalPause();
|
|
340
|
+
this.renderController();
|
|
423
341
|
}
|
|
424
342
|
}, 1000 / speed);
|
|
425
343
|
this.states.state = 'play';
|
|
426
344
|
!preventEvent && ((_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onPlay) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
427
|
-
}
|
|
428
|
-
|
|
345
|
+
}
|
|
346
|
+
play() {
|
|
429
347
|
this.internalPlay();
|
|
430
|
-
}
|
|
431
|
-
|
|
348
|
+
}
|
|
349
|
+
internalPause(preventEvent) {
|
|
432
350
|
var _a, _b;
|
|
433
351
|
clearInterval(this.playInterval);
|
|
434
352
|
this.states.state = 'pause';
|
|
435
353
|
!preventEvent && ((_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onPause) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
436
|
-
}
|
|
437
|
-
|
|
354
|
+
}
|
|
355
|
+
pause() {
|
|
438
356
|
this.internalPause();
|
|
439
|
-
}
|
|
440
|
-
|
|
357
|
+
}
|
|
358
|
+
internalForward(preventEvent) {
|
|
441
359
|
var _a, _b;
|
|
442
|
-
|
|
360
|
+
const indexes = this.moveSelection('forward', preventEvent);
|
|
443
361
|
if (!preventEvent) {
|
|
444
362
|
(_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onForward) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
445
363
|
this.dispatchOnChange();
|
|
446
364
|
}
|
|
447
365
|
return indexes;
|
|
448
|
-
}
|
|
449
|
-
|
|
366
|
+
}
|
|
367
|
+
forward() {
|
|
450
368
|
this.internalForward();
|
|
451
|
-
}
|
|
452
|
-
|
|
369
|
+
}
|
|
370
|
+
handleSpeedChange(value) {
|
|
453
371
|
var _a, _b;
|
|
454
372
|
this.states.speed = value;
|
|
455
|
-
|
|
373
|
+
const { state } = this.states;
|
|
456
374
|
if (state === 'play') {
|
|
457
375
|
// 重新设定 interval
|
|
458
376
|
this.internalPause(true);
|
|
459
377
|
this.internalPlay(true);
|
|
460
378
|
}
|
|
461
379
|
(_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onSpeedChange) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
462
|
-
}
|
|
463
|
-
|
|
380
|
+
}
|
|
381
|
+
handleSelectionTypeChange(type) {
|
|
464
382
|
var _a, _b;
|
|
465
383
|
this.states.selectionType = type;
|
|
466
384
|
this.renderChart();
|
|
467
385
|
(_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onSelectionTypeChange) === null || _b === void 0 ? void 0 : _b.call(_a, type);
|
|
468
|
-
}
|
|
469
|
-
|
|
386
|
+
}
|
|
387
|
+
handleChartTypeChange(type) {
|
|
470
388
|
var _a, _b;
|
|
471
389
|
this.states.chartType = type;
|
|
472
390
|
this.renderChart();
|
|
473
391
|
(_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onChartTypeChange) === null || _b === void 0 ? void 0 : _b.call(_a, type);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
392
|
+
}
|
|
393
|
+
constructor(options) {
|
|
394
|
+
super(deepAssign({}, Timebar.defaultOptions, options));
|
|
395
|
+
this.axis = this.appendChild(new Axis({
|
|
396
|
+
style: { type: 'linear', startPos: [0, 0], endPos: [0, 0], data: [], showArrow: false, animate: false },
|
|
397
|
+
}));
|
|
398
|
+
/** 时间线 group,用于放置 timeline 或者 chart */
|
|
399
|
+
this.timeline = this.appendChild(new Slider({
|
|
400
|
+
style: {
|
|
401
|
+
onChange: (values) => {
|
|
402
|
+
this.handleSliderChange(values);
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
}));
|
|
406
|
+
this.controller = this.appendChild(new Controller({}));
|
|
407
|
+
this.states = {};
|
|
408
|
+
this.handleSliderChange = (values) => {
|
|
409
|
+
const prevValues = (() => {
|
|
410
|
+
const val = this.states.values;
|
|
411
|
+
if (Array.isArray(val))
|
|
412
|
+
return [...val];
|
|
413
|
+
return val;
|
|
414
|
+
})();
|
|
415
|
+
this.setBySliderValues(values);
|
|
416
|
+
this.dispatchOnChange(prevValues);
|
|
417
|
+
};
|
|
418
|
+
const { selectionType, chartType, speed, state, playMode, values } = this.attributes;
|
|
419
|
+
this.states = { chartType, playMode, selectionType, speed, state };
|
|
420
|
+
this.setByTimebarValues(values);
|
|
421
|
+
}
|
|
422
|
+
render() {
|
|
423
|
+
const { axisBBox, controllerBBox, timelineBBox } = this.space;
|
|
477
424
|
this.renderController(controllerBBox);
|
|
478
425
|
this.renderAxis(axisBBox);
|
|
479
426
|
this.renderChart(timelineBBox);
|
|
480
427
|
if (this.states.state === 'play')
|
|
481
428
|
this.internalPlay();
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
|
|
429
|
+
}
|
|
430
|
+
destroy() {
|
|
431
|
+
super.destroy();
|
|
485
432
|
this.internalPause(true);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
}(Component));
|
|
514
|
-
export { Timebar };
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
Timebar.defaultOptions = {
|
|
436
|
+
style: {
|
|
437
|
+
x: 0,
|
|
438
|
+
y: 0,
|
|
439
|
+
axisLabelFill: '#6e6e6e',
|
|
440
|
+
axisLabelTextAlign: 'left',
|
|
441
|
+
axisLabelTextBaseline: 'top',
|
|
442
|
+
axisLabelTransform: 'translate(5, -12)',
|
|
443
|
+
axisLineLineWidth: 1,
|
|
444
|
+
axisLineStroke: '#cacdd1',
|
|
445
|
+
axisTickLength: 15,
|
|
446
|
+
axisTickLineWidth: 1,
|
|
447
|
+
axisTickStroke: '#cacdd1',
|
|
448
|
+
chartShowLabel: false,
|
|
449
|
+
chartType: 'line',
|
|
450
|
+
controllerAlign: 'center',
|
|
451
|
+
controllerHeight: 40,
|
|
452
|
+
data: [],
|
|
453
|
+
interval: 'day',
|
|
454
|
+
loop: false,
|
|
455
|
+
playMode: 'acc',
|
|
456
|
+
selectionType: 'range',
|
|
457
|
+
type: 'time',
|
|
458
|
+
},
|
|
459
|
+
};
|
|
515
460
|
//# sourceMappingURL=timebar.js.map
|