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