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