@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
package/esm/ui/slider/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign, __extends, __read } from "tslib";
|
|
2
1
|
import { CustomEvent } from '@antv/g';
|
|
3
2
|
import { clamp } from '@antv/util';
|
|
4
3
|
import { transition } from '../../animation';
|
|
@@ -8,308 +7,268 @@ import { getEventPos, ifShow, parseSeriesAttr, select, subStyleProps, superStyle
|
|
|
8
7
|
import { Sparkline } from '../sparkline';
|
|
9
8
|
import { CLASS_NAMES, HANDLE_DEFAULT_CFG, HANDLE_ICON_DEFAULT_CFG, HANDLE_LABEL_DEFAULT_CFG } from './constant';
|
|
10
9
|
import { Handle } from './handle';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
export class Slider extends Component {
|
|
11
|
+
get values() {
|
|
12
|
+
return this.attributes.values;
|
|
13
|
+
}
|
|
14
|
+
set values(values) {
|
|
15
|
+
this.attributes.values = this.clampValues(values);
|
|
16
|
+
}
|
|
17
|
+
get sparklineStyle() {
|
|
18
|
+
const { orientation } = this.attributes;
|
|
19
|
+
if (orientation !== 'horizontal')
|
|
20
|
+
return null;
|
|
21
|
+
const attr = subStyleProps(this.attributes, 'sparkline');
|
|
22
|
+
return Object.assign(Object.assign({ zIndex: 0 }, this.availableSpace), attr);
|
|
23
|
+
}
|
|
24
|
+
get shape() {
|
|
25
|
+
const { trackLength, trackSize } = this.attributes;
|
|
26
|
+
const [width, height] = this.getOrientVal([
|
|
27
|
+
[trackLength, trackSize],
|
|
28
|
+
[trackSize, trackLength],
|
|
29
|
+
]);
|
|
30
|
+
return { width, height };
|
|
31
|
+
}
|
|
32
|
+
get availableSpace() {
|
|
33
|
+
const { x, y, padding } = this.attributes;
|
|
34
|
+
const [top, right, bottom, left] = parseSeriesAttr(padding);
|
|
35
|
+
const { width, height } = this.shape;
|
|
36
|
+
return {
|
|
37
|
+
x: left,
|
|
38
|
+
y: top,
|
|
39
|
+
width: width - (left + right),
|
|
40
|
+
height: height - (top + bottom),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
constructor(options) {
|
|
44
|
+
super(options, Object.assign(Object.assign(Object.assign({ x: 0, y: 0, animate: { duration: 100, fill: 'both' }, brushable: true, formatter: (val) => val.toString(), handleSpacing: 2, orientation: 'horizontal', padding: 0, autoFitLabel: true, scrollable: true, selectionFill: '#5B8FF9', selectionFillOpacity: 0.45, selectionZIndex: 2, showHandle: true, showLabel: true, slidable: true, trackFill: '#416180', trackLength: 200, trackOpacity: 0.05, trackSize: 20, trackZIndex: -1, values: [0, 1], type: 'range', selectionType: 'select', handleIconOffset: 0 }, superStyleProps(HANDLE_DEFAULT_CFG, 'handle')), superStyleProps(HANDLE_ICON_DEFAULT_CFG, 'handleIcon')), superStyleProps(HANDLE_LABEL_DEFAULT_CFG, 'handleLabel')));
|
|
45
|
+
this.range = [0, 1];
|
|
46
|
+
this.onDragStart = (target) => (e) => {
|
|
17
47
|
e.stopPropagation();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
document.addEventListener('pointermove',
|
|
25
|
-
document.addEventListener('pointerup',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
this.target = target;
|
|
49
|
+
this.prevPos = this.getOrientVal(getEventPos(e));
|
|
50
|
+
const { x, y } = this.availableSpace;
|
|
51
|
+
const { x: X, y: Y } = this.getBBox();
|
|
52
|
+
this.selectionStartPos = this.getRatio(this.prevPos - this.getOrientVal([x, y]) - this.getOrientVal([+X, +Y]));
|
|
53
|
+
this.selectionWidth = 0;
|
|
54
|
+
document.addEventListener('pointermove', this.onDragging);
|
|
55
|
+
document.addEventListener('pointerup', this.onDragEnd);
|
|
56
|
+
};
|
|
57
|
+
this.onDragging = (e) => {
|
|
58
|
+
const { slidable, brushable, type } = this.attributes;
|
|
29
59
|
e.stopPropagation();
|
|
30
|
-
|
|
31
|
-
|
|
60
|
+
const currPos = this.getOrientVal(getEventPos(e));
|
|
61
|
+
const diffPos = currPos - this.prevPos;
|
|
32
62
|
if (!diffPos)
|
|
33
63
|
return;
|
|
34
|
-
|
|
35
|
-
switch (
|
|
64
|
+
const deltaVal = this.getRatio(diffPos);
|
|
65
|
+
switch (this.target) {
|
|
36
66
|
case 'start':
|
|
37
67
|
if (slidable)
|
|
38
|
-
|
|
68
|
+
this.setValuesOffset(deltaVal);
|
|
39
69
|
break;
|
|
40
70
|
case 'end':
|
|
41
71
|
if (slidable)
|
|
42
|
-
|
|
72
|
+
this.setValuesOffset(0, deltaVal);
|
|
43
73
|
break;
|
|
44
74
|
case 'selection':
|
|
45
75
|
if (slidable)
|
|
46
|
-
|
|
76
|
+
this.setValuesOffset(deltaVal, deltaVal);
|
|
47
77
|
break;
|
|
48
78
|
case 'track':
|
|
49
79
|
if (!brushable)
|
|
50
80
|
return;
|
|
51
81
|
// 绘制蒙板
|
|
52
|
-
|
|
82
|
+
this.selectionWidth += deltaVal;
|
|
53
83
|
if (type === 'range') {
|
|
54
|
-
|
|
84
|
+
this.innerSetValues([this.selectionStartPos, this.selectionStartPos + this.selectionWidth].sort(), true);
|
|
55
85
|
}
|
|
56
86
|
else
|
|
57
|
-
|
|
87
|
+
this.innerSetValues([0, this.selectionStartPos + this.selectionWidth], true);
|
|
58
88
|
break;
|
|
59
89
|
default:
|
|
60
90
|
break;
|
|
61
91
|
}
|
|
62
|
-
|
|
92
|
+
this.prevPos = currPos;
|
|
63
93
|
};
|
|
64
|
-
|
|
65
|
-
document.removeEventListener('pointermove',
|
|
66
|
-
document.removeEventListener('pointermove',
|
|
67
|
-
document.removeEventListener('pointerup',
|
|
68
|
-
|
|
94
|
+
this.onDragEnd = () => {
|
|
95
|
+
document.removeEventListener('pointermove', this.onDragging);
|
|
96
|
+
document.removeEventListener('pointermove', this.onDragging);
|
|
97
|
+
document.removeEventListener('pointerup', this.onDragEnd);
|
|
98
|
+
this.target = '';
|
|
69
99
|
// 更新 handle 状态
|
|
70
|
-
|
|
100
|
+
this.updateHandlesPosition(false);
|
|
71
101
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
detail: { oldValue: internalOldValue, value
|
|
102
|
+
this.onValueChange = (oldValue) => {
|
|
103
|
+
const { onChange, type } = this.attributes;
|
|
104
|
+
const internalOldValue = type === 'range' ? oldValue : oldValue[1];
|
|
105
|
+
const value = type === 'range' ? this.getValues() : this.getValues()[1];
|
|
106
|
+
const evt = new CustomEvent('valuechange', {
|
|
107
|
+
detail: { oldValue: internalOldValue, value },
|
|
78
108
|
});
|
|
79
|
-
|
|
109
|
+
this.dispatchEvent(evt);
|
|
80
110
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
81
111
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Object.defineProperty(Slider.prototype, "values", {
|
|
89
|
-
get: function () {
|
|
90
|
-
return this.attributes.values;
|
|
91
|
-
},
|
|
92
|
-
set: function (values) {
|
|
93
|
-
this.attributes.values = this.clampValues(values);
|
|
94
|
-
},
|
|
95
|
-
enumerable: false,
|
|
96
|
-
configurable: true
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(Slider.prototype, "sparklineStyle", {
|
|
99
|
-
get: function () {
|
|
100
|
-
var orientation = this.attributes.orientation;
|
|
101
|
-
if (orientation !== 'horizontal')
|
|
102
|
-
return null;
|
|
103
|
-
var attr = subStyleProps(this.attributes, 'sparkline');
|
|
104
|
-
return __assign(__assign({ zIndex: 0 }, this.availableSpace), attr);
|
|
105
|
-
},
|
|
106
|
-
enumerable: false,
|
|
107
|
-
configurable: true
|
|
108
|
-
});
|
|
109
|
-
Object.defineProperty(Slider.prototype, "shape", {
|
|
110
|
-
get: function () {
|
|
111
|
-
var _a = this.attributes, trackLength = _a.trackLength, trackSize = _a.trackSize;
|
|
112
|
-
var _b = __read(this.getOrientVal([
|
|
113
|
-
[trackLength, trackSize],
|
|
114
|
-
[trackSize, trackLength],
|
|
115
|
-
]), 2), width = _b[0], height = _b[1];
|
|
116
|
-
return { width: width, height: height };
|
|
117
|
-
},
|
|
118
|
-
enumerable: false,
|
|
119
|
-
configurable: true
|
|
120
|
-
});
|
|
121
|
-
Object.defineProperty(Slider.prototype, "availableSpace", {
|
|
122
|
-
get: function () {
|
|
123
|
-
var _a = this.attributes, x = _a.x, y = _a.y, padding = _a.padding;
|
|
124
|
-
var _b = __read(parseSeriesAttr(padding), 4), top = _b[0], right = _b[1], bottom = _b[2], left = _b[3];
|
|
125
|
-
var _c = this.shape, width = _c.width, height = _c.height;
|
|
126
|
-
return {
|
|
127
|
-
x: left,
|
|
128
|
-
y: top,
|
|
129
|
-
width: width - (left + right),
|
|
130
|
-
height: height - (top + bottom),
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
enumerable: false,
|
|
134
|
-
configurable: true
|
|
135
|
-
});
|
|
136
|
-
Slider.prototype.getValues = function () {
|
|
112
|
+
this.selectionStartPos = 0;
|
|
113
|
+
this.selectionWidth = 0;
|
|
114
|
+
this.prevPos = 0;
|
|
115
|
+
this.target = '';
|
|
116
|
+
}
|
|
117
|
+
getValues() {
|
|
137
118
|
return this.values;
|
|
138
|
-
}
|
|
119
|
+
}
|
|
139
120
|
/** 不触发重绘 */
|
|
140
|
-
|
|
141
|
-
if (values === void 0) { values = [0, 0]; }
|
|
142
|
-
if (animate === void 0) { animate = false; }
|
|
121
|
+
setValues(values = [0, 0], animate = false) {
|
|
143
122
|
this.attributes.values = values;
|
|
144
|
-
|
|
123
|
+
const animation = animate === false ? false : this.attributes.animate;
|
|
145
124
|
this.updateSelectionArea(animation);
|
|
146
125
|
this.updateHandlesPosition(animation);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
126
|
+
}
|
|
127
|
+
updateSelectionArea(animation) {
|
|
128
|
+
const newSelectionArea = this.calcSelectionArea();
|
|
150
129
|
this.foregroundGroup.selectAll(CLASS_NAMES.selection.class).each(function (datum, index) {
|
|
151
130
|
transition(this, newSelectionArea[index], animation);
|
|
152
131
|
});
|
|
153
|
-
}
|
|
154
|
-
|
|
132
|
+
}
|
|
133
|
+
updateHandlesPosition(animation) {
|
|
155
134
|
if (!this.attributes.showHandle)
|
|
156
135
|
return;
|
|
157
136
|
this.startHandle && transition(this.startHandle, this.getHandleStyle('start'), animation);
|
|
158
137
|
this.endHandle && transition(this.endHandle, this.getHandleStyle('end'), animation);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var oldValues = this.values;
|
|
164
|
-
var newValues = this.clampValues(values);
|
|
138
|
+
}
|
|
139
|
+
innerSetValues(values = [0, 0], trigger = false) {
|
|
140
|
+
const oldValues = this.values;
|
|
141
|
+
const newValues = this.clampValues(values);
|
|
165
142
|
this.attributes.values = newValues;
|
|
166
143
|
this.setValues(newValues);
|
|
167
144
|
if (trigger) {
|
|
168
145
|
this.onValueChange(oldValues);
|
|
169
146
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
147
|
+
}
|
|
148
|
+
renderTrack(container) {
|
|
149
|
+
const { x, y } = this.attributes;
|
|
150
|
+
const style = subStyleProps(this.attributes, 'track');
|
|
174
151
|
this.trackShape = select(container)
|
|
175
152
|
.maybeAppendByClassName(CLASS_NAMES.track, 'rect')
|
|
176
|
-
.styles(
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
153
|
+
.styles(Object.assign(Object.assign({ x, y }, this.shape), style));
|
|
154
|
+
}
|
|
155
|
+
renderBrushArea(container) {
|
|
156
|
+
const { x, y, brushable } = this.attributes;
|
|
180
157
|
this.brushArea = select(container)
|
|
181
158
|
.maybeAppendByClassName(CLASS_NAMES.brushArea, 'rect')
|
|
182
|
-
.styles(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
ifShow(orientation === 'horizontal', sparklineGroup,
|
|
189
|
-
|
|
190
|
-
group.maybeAppendByClassName(CLASS_NAMES.sparkline,
|
|
159
|
+
.styles(Object.assign({ x,
|
|
160
|
+
y, fill: 'transparent', cursor: brushable ? 'crosshair' : 'default' }, this.shape));
|
|
161
|
+
}
|
|
162
|
+
renderSparkline(container) {
|
|
163
|
+
const { x, y, orientation } = this.attributes;
|
|
164
|
+
const sparklineGroup = select(container).maybeAppendByClassName(CLASS_NAMES.sparklineGroup, 'g');
|
|
165
|
+
ifShow(orientation === 'horizontal', sparklineGroup, (group) => {
|
|
166
|
+
const style = Object.assign(Object.assign({}, this.sparklineStyle), { x, y });
|
|
167
|
+
group.maybeAppendByClassName(CLASS_NAMES.sparkline, () => new Sparkline({ style })).update(style);
|
|
191
168
|
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
var _this = this;
|
|
169
|
+
}
|
|
170
|
+
renderHandles() {
|
|
195
171
|
var _a;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
(_a = this.foregroundGroup) === null || _a === void 0 ? void 0 : _a.selectAll(CLASS_NAMES.handle.class).data(data.map(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}, function (exit) {
|
|
219
|
-
return exit
|
|
220
|
-
.each(function (_a) {
|
|
221
|
-
var type = _a.type;
|
|
222
|
-
var name = "".concat(type, "Handle");
|
|
223
|
-
that[name] = undefined;
|
|
224
|
-
})
|
|
225
|
-
.remove();
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
Slider.prototype.renderSelection = function (container) {
|
|
229
|
-
var _a = this.attributes, x = _a.x, y = _a.y, type = _a.type, selectionType = _a.selectionType;
|
|
172
|
+
const { showHandle, type } = this.attributes;
|
|
173
|
+
const availableHandle = type === 'range' ? ['start', 'end'] : ['end'];
|
|
174
|
+
const data = showHandle ? availableHandle : [];
|
|
175
|
+
const that = this;
|
|
176
|
+
(_a = this.foregroundGroup) === null || _a === void 0 ? void 0 : _a.selectAll(CLASS_NAMES.handle.class).data(data.map((type) => ({ type })), (d) => d.type).join((enter) => enter
|
|
177
|
+
.append(({ type }) => new Handle({ style: this.getHandleStyle(type) }))
|
|
178
|
+
.each(function ({ type }) {
|
|
179
|
+
this.attr('class', `${CLASS_NAMES.handle.name} ${type}-handle`);
|
|
180
|
+
const name = `${type}Handle`;
|
|
181
|
+
that[name] = this;
|
|
182
|
+
this.addEventListener('pointerdown', that.onDragStart(type));
|
|
183
|
+
}), (update) => update.each(function ({ type }) {
|
|
184
|
+
this.update(that.getHandleStyle(type));
|
|
185
|
+
}), (exit) => exit
|
|
186
|
+
.each(({ type }) => {
|
|
187
|
+
const name = `${type}Handle`;
|
|
188
|
+
that[name] = undefined;
|
|
189
|
+
})
|
|
190
|
+
.remove());
|
|
191
|
+
}
|
|
192
|
+
renderSelection(container) {
|
|
193
|
+
const { x, y, type, selectionType } = this.attributes;
|
|
230
194
|
this.foregroundGroup = select(container).maybeAppendByClassName(CLASS_NAMES.foreground, 'g');
|
|
231
195
|
// value 类型的 slider 不渲染选区
|
|
232
|
-
|
|
233
|
-
|
|
196
|
+
const selectionStyle = subStyleProps(this.attributes, 'selection');
|
|
197
|
+
const applyStyle = (selection) => {
|
|
234
198
|
return selection
|
|
235
|
-
.style('visibility',
|
|
236
|
-
.style('cursor',
|
|
199
|
+
.style('visibility', (d) => (d.show ? 'visible' : 'hidden'))
|
|
200
|
+
.style('cursor', (d) => {
|
|
237
201
|
if (selectionType === 'select')
|
|
238
202
|
return 'grab';
|
|
239
203
|
if (selectionType === 'invert')
|
|
240
204
|
return 'crosshair';
|
|
241
205
|
return 'default';
|
|
242
206
|
})
|
|
243
|
-
.styles(
|
|
207
|
+
.styles(Object.assign(Object.assign({}, selectionStyle), { transform: `translate(${x}, ${y})` }));
|
|
244
208
|
};
|
|
245
|
-
|
|
209
|
+
const that = this;
|
|
246
210
|
this.foregroundGroup
|
|
247
211
|
.selectAll(CLASS_NAMES.selection.class)
|
|
248
212
|
.data(type === 'value'
|
|
249
213
|
? []
|
|
250
|
-
: this.calcSelectionArea().map(
|
|
251
|
-
style:
|
|
252
|
-
index
|
|
214
|
+
: this.calcSelectionArea().map((area, index) => ({
|
|
215
|
+
style: Object.assign({}, area),
|
|
216
|
+
index,
|
|
253
217
|
// 是否可见
|
|
254
218
|
show: selectionType === 'select' ? index === 1 : index !== 1,
|
|
255
|
-
})
|
|
256
|
-
.join(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}, function (update) { return update.call(applyStyle); }, function (exit) { return exit.remove(); });
|
|
219
|
+
})), (d) => d.index)
|
|
220
|
+
.join((enter) => enter
|
|
221
|
+
.append('rect')
|
|
222
|
+
.attr('className', CLASS_NAMES.selection.name)
|
|
223
|
+
.call(applyStyle)
|
|
224
|
+
.each(function (datum, index) {
|
|
225
|
+
if (index === 1) {
|
|
226
|
+
that.selectionShape = select(this);
|
|
227
|
+
// 选区drag事件
|
|
228
|
+
this.on('pointerdown', (e) => {
|
|
229
|
+
this.attr('cursor', 'grabbing');
|
|
230
|
+
that.onDragStart('selection')(e);
|
|
231
|
+
});
|
|
232
|
+
// 选区hover事件
|
|
233
|
+
that.dispatchCustomEvent(this, 'pointerenter', 'selectionMouseenter');
|
|
234
|
+
that.dispatchCustomEvent(this, 'pointerleave', 'selectionMouseleave');
|
|
235
|
+
that.dispatchCustomEvent(this, 'click', 'selectionClick');
|
|
236
|
+
// 拖拽交互
|
|
237
|
+
this.addEventListener('pointerdown', () => {
|
|
238
|
+
this.attr('cursor', 'grabbing');
|
|
239
|
+
});
|
|
240
|
+
this.addEventListener('pointerup', () => {
|
|
241
|
+
this.attr('cursor', 'pointer');
|
|
242
|
+
});
|
|
243
|
+
this.addEventListener('pointerover', () => {
|
|
244
|
+
this.attr('cursor', 'pointer');
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
this.on('pointerdown', that.onDragStart('track'));
|
|
249
|
+
}
|
|
250
|
+
}), (update) => update.call(applyStyle), (exit) => exit.remove());
|
|
290
251
|
this.updateSelectionArea(false);
|
|
291
252
|
this.renderHandles();
|
|
292
|
-
}
|
|
293
|
-
|
|
253
|
+
}
|
|
254
|
+
render(attributes, container) {
|
|
294
255
|
this.renderTrack(container);
|
|
295
256
|
this.renderSparkline(container);
|
|
296
257
|
this.renderBrushArea(container);
|
|
297
258
|
this.renderSelection(container);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
var internalValues = Array.isArray(values) ? values : [prevStart, values !== null && values !== void 0 ? values : prevEnd];
|
|
305
|
-
var _d = __read((internalValues || [prevStart, prevEnd]).map(function (num) { return toPrecision(num, precision); }), 2), startVal = _d[0], endVal = _d[1];
|
|
259
|
+
}
|
|
260
|
+
clampValues(values, precision = 4) {
|
|
261
|
+
const [min, max] = this.range;
|
|
262
|
+
const [prevStart, prevEnd] = this.getValues().map((num) => toPrecision(num, precision));
|
|
263
|
+
const internalValues = Array.isArray(values) ? values : [prevStart, values !== null && values !== void 0 ? values : prevEnd];
|
|
264
|
+
let [startVal, endVal] = (internalValues || [prevStart, prevEnd]).map((num) => toPrecision(num, precision));
|
|
306
265
|
if (this.attributes.type === 'value')
|
|
307
266
|
return [0, clamp(endVal, min, max)];
|
|
308
267
|
// 交换startVal endVal
|
|
309
268
|
if (startVal > endVal) {
|
|
310
|
-
|
|
269
|
+
[startVal, endVal] = [endVal, startVal];
|
|
311
270
|
}
|
|
312
|
-
|
|
271
|
+
const range = endVal - startVal;
|
|
313
272
|
// 超出范围就全选
|
|
314
273
|
if (range > max - min)
|
|
315
274
|
return [min, max];
|
|
@@ -325,44 +284,44 @@ var Slider = /** @class */ (function (_super) {
|
|
|
325
284
|
}
|
|
326
285
|
// 保留小数
|
|
327
286
|
return [startVal, endVal];
|
|
328
|
-
}
|
|
287
|
+
}
|
|
329
288
|
/**
|
|
330
289
|
* 计算选区坐标和宽高
|
|
331
290
|
* 默认用来计算前景位置大小
|
|
332
291
|
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
292
|
+
calcSelectionArea(values) {
|
|
293
|
+
const [start, end] = this.clampValues(values);
|
|
294
|
+
const { x, y, width, height } = this.availableSpace;
|
|
336
295
|
// 中间为选区,两端为反选区
|
|
337
296
|
return this.getOrientVal([
|
|
338
297
|
[
|
|
339
|
-
{ y
|
|
340
|
-
{ y
|
|
341
|
-
{ y
|
|
298
|
+
{ y, height, x, width: start * width },
|
|
299
|
+
{ y, height, x: start * width + x, width: (end - start) * width },
|
|
300
|
+
{ y, height, x: end * width, width: (1 - end) * width },
|
|
342
301
|
],
|
|
343
302
|
[
|
|
344
|
-
{ x
|
|
345
|
-
{ x
|
|
346
|
-
{ x
|
|
303
|
+
{ x, width, y, height: start * height },
|
|
304
|
+
{ x, width, y: start * height + y, height: (end - start) * height },
|
|
305
|
+
{ x, width, y: end * height, height: (1 - end) * height },
|
|
347
306
|
],
|
|
348
307
|
]);
|
|
349
|
-
}
|
|
308
|
+
}
|
|
350
309
|
/**
|
|
351
310
|
* 计算手柄的x y
|
|
352
311
|
*/
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
312
|
+
calcHandlePosition(handleType) {
|
|
313
|
+
const { handleIconOffset } = this.attributes;
|
|
314
|
+
const { x, y, width, height } = this.availableSpace;
|
|
315
|
+
const [stVal, endVal] = this.clampValues();
|
|
316
|
+
const offset = handleType === 'start' ? -handleIconOffset : handleIconOffset;
|
|
317
|
+
const L = (handleType === 'start' ? stVal : endVal) * this.getOrientVal([width, height]) + offset;
|
|
359
318
|
return {
|
|
360
319
|
x: x + this.getOrientVal([L, width / 2]),
|
|
361
320
|
y: y + this.getOrientVal([height / 2, L]),
|
|
362
321
|
};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
322
|
+
}
|
|
323
|
+
inferTextStyle(handleType) {
|
|
324
|
+
const { orientation } = this.attributes;
|
|
366
325
|
if (orientation === 'horizontal')
|
|
367
326
|
return {};
|
|
368
327
|
if (handleType === 'start')
|
|
@@ -370,54 +329,53 @@ var Slider = /** @class */ (function (_super) {
|
|
|
370
329
|
if (handleType === 'end')
|
|
371
330
|
return { transformOrigin: 'right center', transform: [['rotate', 90]], textAlign: 'end' };
|
|
372
331
|
return {};
|
|
373
|
-
}
|
|
332
|
+
}
|
|
374
333
|
/**
|
|
375
334
|
* 计算手柄应当处于的位置
|
|
376
335
|
* @param handleType start手柄还是end手柄
|
|
377
336
|
* @returns
|
|
378
337
|
*/
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
style: __assign(__assign(__assign({}, labelStyle), this.inferTextStyle(handleType)), { text: text }),
|
|
338
|
+
calcHandleText(handleType) {
|
|
339
|
+
const { type, orientation, formatter, autoFitLabel } = this.attributes;
|
|
340
|
+
const handleStyle = subStyleProps(this.attributes, 'handle');
|
|
341
|
+
const labelStyle = subStyleProps(handleStyle, 'label');
|
|
342
|
+
const { spacing } = handleStyle;
|
|
343
|
+
const size = this.getHandleSize();
|
|
344
|
+
const values = this.clampValues();
|
|
345
|
+
const value = handleType === 'start' ? values[0] : values[1];
|
|
346
|
+
const text = formatter(value);
|
|
347
|
+
const temp = new Text({
|
|
348
|
+
style: Object.assign(Object.assign(Object.assign({}, labelStyle), this.inferTextStyle(handleType)), { text }),
|
|
391
349
|
});
|
|
392
350
|
// 文字包围盒的宽高
|
|
393
|
-
|
|
351
|
+
const { width: textWidth, height: textHeight } = temp.getBBox();
|
|
394
352
|
temp.destroy();
|
|
395
353
|
if (!autoFitLabel) {
|
|
396
354
|
if (type === 'value')
|
|
397
|
-
return { text
|
|
398
|
-
|
|
399
|
-
return
|
|
355
|
+
return { text, x: 0, y: -textHeight - spacing };
|
|
356
|
+
const finaleWidth = spacing + size + (orientation === 'horizontal' ? textWidth / 2 : 0);
|
|
357
|
+
return { text, [orientation === 'horizontal' ? 'x' : 'y']: handleType === 'start' ? -finaleWidth : finaleWidth };
|
|
400
358
|
}
|
|
401
|
-
|
|
402
|
-
|
|
359
|
+
let x = 0;
|
|
360
|
+
let y = 0;
|
|
403
361
|
// 相对于获取两端可用空间
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
362
|
+
const { width: iW, height: iH } = this.availableSpace;
|
|
363
|
+
const { x: fX, y: fY, width: fW, height: fH } = this.calcSelectionArea()[1];
|
|
364
|
+
const totalSpacing = spacing + size;
|
|
407
365
|
if (orientation === 'horizontal') {
|
|
408
|
-
|
|
366
|
+
const finalWidth = totalSpacing + textWidth / 2;
|
|
409
367
|
if (handleType === 'start') {
|
|
410
|
-
|
|
368
|
+
const left = fX - totalSpacing - textWidth;
|
|
411
369
|
x = left > 0 ? -finalWidth : finalWidth;
|
|
412
370
|
}
|
|
413
371
|
else {
|
|
414
|
-
|
|
372
|
+
const sign = iW - fX - fW - totalSpacing > textWidth;
|
|
415
373
|
x = sign ? finalWidth : -finalWidth;
|
|
416
374
|
}
|
|
417
375
|
}
|
|
418
376
|
else {
|
|
419
|
-
|
|
420
|
-
|
|
377
|
+
const positiveSize = totalSpacing;
|
|
378
|
+
const negativeSize = textHeight + totalSpacing;
|
|
421
379
|
if (handleType === 'start') {
|
|
422
380
|
y = fY - size > textHeight ? -negativeSize : positiveSize;
|
|
423
381
|
}
|
|
@@ -425,88 +383,84 @@ var Slider = /** @class */ (function (_super) {
|
|
|
425
383
|
y = iH - (fY + fH) - size > textHeight ? negativeSize : -positiveSize;
|
|
426
384
|
}
|
|
427
385
|
}
|
|
428
|
-
return { x
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
return
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
386
|
+
return { x, y, text };
|
|
387
|
+
}
|
|
388
|
+
getHandleLabelStyle(handleType) {
|
|
389
|
+
const style = subStyleProps(this.attributes, 'handleLabel');
|
|
390
|
+
return Object.assign(Object.assign(Object.assign({}, style), this.calcHandleText(handleType)), this.inferTextStyle(handleType));
|
|
391
|
+
}
|
|
392
|
+
getHandleIconStyle() {
|
|
393
|
+
const { handleIconShape: shape } = this.attributes;
|
|
394
|
+
const style = subStyleProps(this.attributes, 'handleIcon');
|
|
395
|
+
const cursor = this.getOrientVal(['ew-resize', 'ns-resize']);
|
|
396
|
+
const size = this.getHandleSize();
|
|
397
|
+
return Object.assign({ cursor,
|
|
398
|
+
shape,
|
|
399
|
+
size }, style);
|
|
400
|
+
}
|
|
401
|
+
getHandleStyle(handleType) {
|
|
402
|
+
const { x: ox, y: oy, showLabel, showLabelOnInteraction, orientation } = this.attributes;
|
|
403
|
+
const { x, y } = this.calcHandlePosition(handleType);
|
|
404
|
+
const textStyle = this.calcHandleText(handleType);
|
|
405
|
+
let internalShowLabel = showLabel;
|
|
446
406
|
if (!showLabel && showLabelOnInteraction) {
|
|
447
407
|
if (this.target)
|
|
448
408
|
internalShowLabel = true;
|
|
449
409
|
else
|
|
450
410
|
internalShowLabel = false;
|
|
451
411
|
}
|
|
452
|
-
return
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
|
|
412
|
+
return Object.assign(Object.assign(Object.assign({}, superStyleProps(this.getHandleIconStyle(), 'icon')), superStyleProps(Object.assign(Object.assign({}, this.getHandleLabelStyle(handleType)), textStyle), 'label')), { transform: `translate(${x + ox}, ${y + oy})`, orientation, showLabel: internalShowLabel, type: handleType, zIndex: 3 });
|
|
413
|
+
}
|
|
414
|
+
getHandleSize() {
|
|
415
|
+
const { handleIconSize: size, width, height } = this.attributes;
|
|
456
416
|
if (size)
|
|
457
417
|
return size;
|
|
458
418
|
// 没设置 size 的话,高度就取 height + 4 高度,手柄宽度是高度的 1/ 2.4
|
|
459
419
|
return Math.floor((this.getOrientVal([+height, +width]) + 4) / 2.4);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
var orientation = this.attributes.orientation;
|
|
420
|
+
}
|
|
421
|
+
getOrientVal([x, y]) {
|
|
422
|
+
const { orientation } = this.attributes;
|
|
464
423
|
return orientation === 'horizontal' ? x : y;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
var internalStartOffset = type === 'range' ? stOffset : 0;
|
|
472
|
-
var values = [oldStartVal + internalStartOffset, oldEndVal + endOffset].sort();
|
|
424
|
+
}
|
|
425
|
+
setValuesOffset(stOffset, endOffset = 0, animate = false) {
|
|
426
|
+
const { type } = this.attributes;
|
|
427
|
+
const [oldStartVal, oldEndVal] = this.getValues();
|
|
428
|
+
const internalStartOffset = type === 'range' ? stOffset : 0;
|
|
429
|
+
const values = [oldStartVal + internalStartOffset, oldEndVal + endOffset].sort();
|
|
473
430
|
if (animate)
|
|
474
431
|
this.setValues(values);
|
|
475
432
|
else
|
|
476
433
|
this.innerSetValues(values, true);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
434
|
+
}
|
|
435
|
+
getRatio(val) {
|
|
436
|
+
const { width, height } = this.availableSpace;
|
|
480
437
|
return val / this.getOrientVal([width, height]);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
target.on(event, function (e) {
|
|
438
|
+
}
|
|
439
|
+
dispatchCustomEvent(target, event, name) {
|
|
440
|
+
target.on(event, (e) => {
|
|
485
441
|
e.stopPropagation();
|
|
486
|
-
|
|
442
|
+
this.dispatchEvent(new CustomEvent(name, { detail: e }));
|
|
487
443
|
});
|
|
488
|
-
}
|
|
489
|
-
|
|
444
|
+
}
|
|
445
|
+
bindEvents() {
|
|
490
446
|
// scroll 事件
|
|
491
447
|
this.addEventListener('wheel', this.onScroll);
|
|
492
|
-
|
|
448
|
+
const brushArea = this.brushArea;
|
|
493
449
|
this.dispatchCustomEvent(brushArea, 'click', 'trackClick');
|
|
494
450
|
this.dispatchCustomEvent(brushArea, 'pointerenter', 'trackMouseenter');
|
|
495
451
|
this.dispatchCustomEvent(brushArea, 'pointerleave', 'trackMouseleave');
|
|
496
452
|
// Drag and brush
|
|
497
453
|
brushArea.on('pointerdown', this.onDragStart('track'));
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
454
|
+
}
|
|
455
|
+
onScroll(event) {
|
|
456
|
+
const { scrollable } = this.attributes;
|
|
501
457
|
if (scrollable) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
458
|
+
const { deltaX, deltaY } = event;
|
|
459
|
+
const offset = deltaY || deltaX;
|
|
460
|
+
const deltaVal = this.getRatio(offset);
|
|
505
461
|
this.setValuesOffset(deltaVal, deltaVal, true);
|
|
506
462
|
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}(Component));
|
|
511
|
-
export { Slider };
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
Slider.tag = 'slider';
|
|
512
466
|
//# sourceMappingURL=index.js.map
|