@antv/component 2.1.1-alpha.1 → 2.1.1-alpha.2
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.js +68 -67
- 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 +326 -280
- 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.js +66 -65
- 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 +334 -289
- 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 +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __extends, __read, __spreadArray } from "tslib";
|
|
1
2
|
import { CustomEvent } from '@antv/g';
|
|
2
3
|
import { Linear } from '@antv/scale';
|
|
3
4
|
import { clamp, isUndefined } from '@antv/util';
|
|
@@ -15,98 +16,108 @@ import { getNextTickValue } from './continuous/utils';
|
|
|
15
16
|
import { getSafetySelections, getStepValueByValue, ifHorizontal } from './utils';
|
|
16
17
|
function getMinMax(data) {
|
|
17
18
|
return {
|
|
18
|
-
min: Math.min(
|
|
19
|
-
max: Math.max(
|
|
19
|
+
min: Math.min.apply(Math, __spreadArray([], __read(data.map(function (d) { return d.value; })), false)),
|
|
20
|
+
max: Math.max.apply(Math, __spreadArray([], __read(data.map(function (d) { return d.value; })), false)),
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
var Continuous = /** @class */ (function (_super) {
|
|
24
|
+
__extends(Continuous, _super);
|
|
25
|
+
function Continuous(options) {
|
|
26
|
+
var _this = _super.call(this, options, CONTINUOUS_DEFAULT_OPTIONS) || this;
|
|
27
|
+
_this.eventToOffsetScale = new Linear({});
|
|
28
|
+
_this.innerRibbonScale = new Linear({});
|
|
29
|
+
_this.cacheLabelBBox = null;
|
|
30
|
+
_this.cacheHandleBBox = null;
|
|
31
|
+
_this.onHovering = function (e) {
|
|
32
|
+
var _a = _this.attributes, data = _a.data, block = _a.block;
|
|
31
33
|
e.stopPropagation();
|
|
32
|
-
|
|
34
|
+
var value = _this.getValueByCanvasPoint(e);
|
|
33
35
|
if (block) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
var range = getNextTickValue(data.map(function (_a) {
|
|
37
|
+
var value = _a.value;
|
|
38
|
+
return value;
|
|
39
|
+
}), value).range;
|
|
40
|
+
var selection = _this.getRealSelection(range);
|
|
41
|
+
_this.showIndicator((range[0] + range[1]) / 2, "".concat(selection[0], "-").concat(selection[1]));
|
|
42
|
+
_this.dispatchIndicated(value, range);
|
|
38
43
|
}
|
|
39
44
|
else {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
var safetyValue = _this.getTickValue(value);
|
|
46
|
+
_this.showIndicator(safetyValue, "".concat(_this.getRealValue(safetyValue)));
|
|
47
|
+
_this.dispatchIndicated(safetyValue);
|
|
43
48
|
}
|
|
44
49
|
};
|
|
45
|
-
|
|
50
|
+
_this.onDragStart = function (target) { return function (e) {
|
|
46
51
|
e.stopPropagation();
|
|
47
52
|
// 关闭滑动
|
|
48
|
-
if (!
|
|
53
|
+
if (!_this.attributes.slidable)
|
|
49
54
|
return;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
document.addEventListener('mousemove',
|
|
53
|
-
document.addEventListener('touchmove',
|
|
54
|
-
document.addEventListener('mouseleave',
|
|
55
|
-
document.addEventListener('mouseup',
|
|
56
|
-
document.addEventListener('mouseup',
|
|
57
|
-
document.addEventListener('touchend',
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
_this.target = target;
|
|
56
|
+
_this.prevValue = _this.getTickValue(_this.getValueByCanvasPoint(e));
|
|
57
|
+
document.addEventListener('mousemove', _this.onDragging);
|
|
58
|
+
document.addEventListener('touchmove', _this.onDragging);
|
|
59
|
+
document.addEventListener('mouseleave', _this.onDragEnd);
|
|
60
|
+
document.addEventListener('mouseup', _this.onDragEnd);
|
|
61
|
+
document.addEventListener('mouseup', _this.onDragEnd);
|
|
62
|
+
document.addEventListener('touchend', _this.onDragEnd);
|
|
63
|
+
}; };
|
|
64
|
+
_this.onDragging = function (e) {
|
|
65
|
+
var target = _this.target;
|
|
66
|
+
_this.updateMouse();
|
|
67
|
+
var _a = __read(_this.selection, 2), start = _a[0], end = _a[1];
|
|
68
|
+
var currValue = _this.getTickValue(_this.getValueByCanvasPoint(e));
|
|
69
|
+
var diffValue = currValue - _this.prevValue;
|
|
65
70
|
if (target === 'start')
|
|
66
|
-
start !== currValue &&
|
|
71
|
+
start !== currValue && _this.updateSelection(currValue, end);
|
|
67
72
|
else if (target === 'end')
|
|
68
|
-
end !== currValue &&
|
|
73
|
+
end !== currValue && _this.updateSelection(start, currValue);
|
|
69
74
|
else if (target === 'ribbon' && diffValue !== 0) {
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
_this.prevValue = currValue;
|
|
76
|
+
_this.updateSelection(diffValue, diffValue, true);
|
|
72
77
|
}
|
|
73
78
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
document.removeEventListener('mousemove',
|
|
77
|
-
document.removeEventListener('touchmove',
|
|
78
|
-
document.removeEventListener('mouseup',
|
|
79
|
-
document.removeEventListener('touchend',
|
|
79
|
+
_this.onDragEnd = function () {
|
|
80
|
+
_this.style.cursor = 'pointer';
|
|
81
|
+
document.removeEventListener('mousemove', _this.onDragging);
|
|
82
|
+
document.removeEventListener('touchmove', _this.onDragging);
|
|
83
|
+
document.removeEventListener('mouseup', _this.onDragEnd);
|
|
84
|
+
document.removeEventListener('touchend', _this.onDragEnd);
|
|
80
85
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
return _this;
|
|
87
|
+
}
|
|
88
|
+
Object.defineProperty(Continuous.prototype, "handleOffsetRatio", {
|
|
89
|
+
get: function () {
|
|
90
|
+
return this.ifHorizontal(0.5, 0.5);
|
|
91
|
+
},
|
|
92
|
+
enumerable: false,
|
|
93
|
+
configurable: true
|
|
94
|
+
});
|
|
95
|
+
Continuous.prototype.getBBox = function () {
|
|
96
|
+
var _a = this.attributes, width = _a.width, height = _a.height;
|
|
87
97
|
return new BBox(0, 0, width, height);
|
|
88
|
-
}
|
|
89
|
-
render(attributes, container) {
|
|
98
|
+
};
|
|
99
|
+
Continuous.prototype.render = function (attributes, container) {
|
|
100
|
+
var _this = this;
|
|
90
101
|
// 渲染顺序
|
|
91
102
|
// 1. 绘制 title, 获得可用空间
|
|
92
103
|
// 2. 绘制 label, handle
|
|
93
104
|
// 3. 基于可用空间、label高度、handle 宽高,计算 ribbon 宽高
|
|
94
105
|
// 4. 绘制 ribbon
|
|
95
106
|
// 5. 调整 label、handle 位置
|
|
96
|
-
|
|
107
|
+
var showLabel = attributes.showLabel;
|
|
97
108
|
/** title */
|
|
98
109
|
this.renderTitle(select(container));
|
|
99
|
-
|
|
110
|
+
var _a = this.availableSpace, x = _a.x, y = _a.y;
|
|
100
111
|
/** label */
|
|
101
112
|
/** content */
|
|
102
|
-
|
|
113
|
+
var contentGroup = select(container)
|
|
103
114
|
.maybeAppendByClassName(CLASS_NAMES.contentGroup, 'g')
|
|
104
|
-
.styles({ transform:
|
|
105
|
-
|
|
106
|
-
ifShow(!!showLabel, labelGroup, (group)
|
|
107
|
-
|
|
115
|
+
.styles({ transform: "translate(".concat(x, ", ").concat(y, ")") });
|
|
116
|
+
var labelGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles({ zIndex: 1 });
|
|
117
|
+
ifShow(!!showLabel, labelGroup, function (group) {
|
|
118
|
+
_this.renderLabel(group);
|
|
108
119
|
});
|
|
109
|
-
|
|
120
|
+
var ribbonGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.ribbonGroup, 'g').styles({ zIndex: 0 });
|
|
110
121
|
/** handle */
|
|
111
122
|
this.handlesGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.handlesGroup, 'g').styles({ zIndex: 2 });
|
|
112
123
|
this.renderHandles();
|
|
@@ -117,153 +128,201 @@ export class Continuous extends Component {
|
|
|
117
128
|
this.adjustLabel();
|
|
118
129
|
this.adjustHandles();
|
|
119
130
|
// this.adjustTitle();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
131
|
+
};
|
|
132
|
+
Object.defineProperty(Continuous.prototype, "range", {
|
|
133
|
+
get: function () {
|
|
134
|
+
var _a = this.attributes, data = _a.data, domain = _a.domain;
|
|
135
|
+
return domain ? { min: domain[0], max: domain[1] } : getMinMax(data);
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(Continuous.prototype, "ribbonScale", {
|
|
141
|
+
get: function () {
|
|
142
|
+
var _a = this.range, min = _a.min, max = _a.max;
|
|
143
|
+
this.innerRibbonScale.update({
|
|
144
|
+
domain: [min, max],
|
|
145
|
+
range: [0, 1],
|
|
146
|
+
});
|
|
147
|
+
return this.innerRibbonScale;
|
|
148
|
+
},
|
|
149
|
+
enumerable: false,
|
|
150
|
+
configurable: true
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(Continuous.prototype, "ribbonRange", {
|
|
153
|
+
get: function () {
|
|
154
|
+
var _a = __read(this.selection, 2), min = _a[0], max = _a[1];
|
|
155
|
+
var scale = this.ribbonScale;
|
|
156
|
+
return [scale.map(min), scale.map(max)];
|
|
157
|
+
},
|
|
158
|
+
enumerable: false,
|
|
159
|
+
configurable: true
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(Continuous.prototype, "selection", {
|
|
162
|
+
get: function () {
|
|
163
|
+
var _a = this.range, min = _a.min, max = _a.max;
|
|
164
|
+
var _b = this.attributes.defaultValue, _c = _b === void 0 ? [min, max] : _b, _d = __read(_c, 2), start = _d[0], end = _d[1];
|
|
165
|
+
return [start, end];
|
|
166
|
+
},
|
|
167
|
+
enumerable: false,
|
|
168
|
+
configurable: true
|
|
169
|
+
});
|
|
170
|
+
Continuous.prototype.ifHorizontal = function (a, b) {
|
|
144
171
|
return ifHorizontal(this.attributes.orientation, typeof a === 'function' ? a() : a, typeof b === 'function' ? b() : b);
|
|
145
|
-
}
|
|
146
|
-
renderTitle(container) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
};
|
|
173
|
+
Continuous.prototype.renderTitle = function (container) {
|
|
174
|
+
var _a = this.attributes, showTitle = _a.showTitle, titleText = _a.titleText, width = _a.width, height = _a.height;
|
|
175
|
+
var style = subStyleProps(this.attributes, 'title');
|
|
176
|
+
var finalTitleStyle = __assign(__assign({}, style), { width: width, height: height, text: titleText });
|
|
177
|
+
var that = this;
|
|
151
178
|
container
|
|
152
179
|
.selectAll(CLASS_NAMES.title.class)
|
|
153
180
|
.data(showTitle ? [titleText] : [])
|
|
154
|
-
.join((enter)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
.join(function (enter) {
|
|
182
|
+
return enter
|
|
183
|
+
.append(function () { return new Title({ style: finalTitleStyle }); })
|
|
184
|
+
.attr('className', CLASS_NAMES.title.name)
|
|
185
|
+
.each(function () {
|
|
186
|
+
that.title = this;
|
|
187
|
+
});
|
|
188
|
+
}, function (update) { return update.update(finalTitleStyle); }, function (exit) {
|
|
189
|
+
return exit
|
|
190
|
+
.each(function () {
|
|
191
|
+
that.title = undefined;
|
|
192
|
+
})
|
|
193
|
+
.remove();
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
Object.defineProperty(Continuous.prototype, "availableSpace", {
|
|
197
|
+
get: function () {
|
|
198
|
+
if (this.title)
|
|
199
|
+
return this.title.getAvailableSpace();
|
|
200
|
+
var _a = this.attributes, width = _a.width, height = _a.height;
|
|
201
|
+
return new BBox(0, 0, width, height);
|
|
202
|
+
},
|
|
203
|
+
enumerable: false,
|
|
204
|
+
configurable: true
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(Continuous.prototype, "labelFixedSpacing", {
|
|
207
|
+
get: function () {
|
|
208
|
+
var showTick = this.attributes.showTick;
|
|
209
|
+
return showTick ? 5 : 0;
|
|
210
|
+
},
|
|
211
|
+
enumerable: false,
|
|
212
|
+
configurable: true
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(Continuous.prototype, "labelPosition", {
|
|
215
|
+
get: function () {
|
|
216
|
+
var _a = this.attributes, orientation = _a.orientation, labelDirection = _a.labelDirection;
|
|
217
|
+
var positions = {
|
|
218
|
+
vertical: { positive: 'right', negative: 'left' },
|
|
219
|
+
horizontal: { positive: 'bottom', negative: 'top' },
|
|
220
|
+
};
|
|
221
|
+
return positions[orientation][labelDirection];
|
|
222
|
+
},
|
|
223
|
+
enumerable: false,
|
|
224
|
+
configurable: true
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(Continuous.prototype, "labelBBox", {
|
|
227
|
+
get: function () {
|
|
228
|
+
var _a;
|
|
229
|
+
var showLabel = this.attributes.showLabel;
|
|
230
|
+
if (!showLabel)
|
|
231
|
+
return new BBox(0, 0, 0, 0);
|
|
232
|
+
if (this.cacheLabelBBox)
|
|
233
|
+
return this.cacheLabelBBox;
|
|
234
|
+
var _b = ((_a = this.label.querySelector(AXIS_CLASS_NAMES.labelGroup.class)) === null || _a === void 0 ? void 0 : _a.children.slice(-1)[0]).getBBox(), width = _b.width, height = _b.height;
|
|
235
|
+
this.cacheLabelBBox = new BBox(0, 0, width, height);
|
|
189
236
|
return this.cacheLabelBBox;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
237
|
+
},
|
|
238
|
+
enumerable: false,
|
|
239
|
+
configurable: true
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(Continuous.prototype, "labelShape", {
|
|
242
|
+
get: function () {
|
|
243
|
+
var _a = this.attributes, showLabel = _a.showLabel, _b = _a.labelSpacing, labelSpacing = _b === void 0 ? 0 : _b;
|
|
244
|
+
if (!showLabel)
|
|
245
|
+
return { width: 0, height: 0, size: 0, length: 0 };
|
|
246
|
+
var _c = this.labelBBox, width = _c.width, height = _c.height;
|
|
247
|
+
var size = this.ifHorizontal(height, width) + labelSpacing + this.labelFixedSpacing;
|
|
248
|
+
var length = this.ifHorizontal(width, height);
|
|
249
|
+
return { width: width, height: height, size: size, length: length };
|
|
250
|
+
},
|
|
251
|
+
enumerable: false,
|
|
252
|
+
configurable: true
|
|
253
|
+
});
|
|
254
|
+
Object.defineProperty(Continuous.prototype, "ribbonBBox", {
|
|
255
|
+
get: function () {
|
|
256
|
+
var _a = this.attributes, showHandle = _a.showHandle, userDefinedRibbonSize = _a.ribbonSize;
|
|
257
|
+
var _b = this.availableSpace, availableWidth = _b.width, availableHeight = _b.height;
|
|
258
|
+
var _c = this.labelShape, labelSize = _c.size, labelLength = _c.length;
|
|
259
|
+
var _d = __read(this.ifHorizontal([availableHeight, availableWidth], [availableWidth, availableHeight]), 2), availableSize = _d[0], availableLength = _d[1];
|
|
260
|
+
var _e = showHandle ? this.handleShape : { size: 0, length: 0 }, handleSize = _e.size, handleLength = _e.length;
|
|
261
|
+
var handleRatio = this.handleOffsetRatio;
|
|
262
|
+
var ribbonSize = 0;
|
|
263
|
+
var labelPosition = this.labelPosition;
|
|
264
|
+
if (userDefinedRibbonSize) {
|
|
265
|
+
ribbonSize = userDefinedRibbonSize;
|
|
266
|
+
}
|
|
267
|
+
else if (['bottom', 'right'].includes(labelPosition)) {
|
|
268
|
+
ribbonSize = Math.min(availableSize - labelSize, (availableSize - handleSize) / handleRatio);
|
|
269
|
+
}
|
|
270
|
+
else if (availableSize * (1 - handleRatio) > handleSize) {
|
|
271
|
+
ribbonSize = Math.max(availableSize - labelSize, 0);
|
|
272
|
+
}
|
|
273
|
+
else
|
|
274
|
+
ribbonSize = Math.max((availableSize - labelSize - handleSize) / handleRatio, 0);
|
|
275
|
+
var edgeLength = Math.max(handleLength, labelLength);
|
|
276
|
+
var ribbonLength = availableLength - edgeLength;
|
|
277
|
+
var _f = __read(this.ifHorizontal([ribbonLength, ribbonSize], [ribbonSize, ribbonLength]), 2), width = _f[0], height = _f[1];
|
|
278
|
+
// 需要考虑 handle 的占用空间
|
|
279
|
+
// todo 为了防止因为 handle 文本变化导致的 ribbon 位置变化,handle size 取最大值
|
|
280
|
+
var finalLabelOccupy = ['top', 'left'].includes(labelPosition) ? labelSize : 0;
|
|
281
|
+
var _g = __read(this.ifHorizontal([edgeLength / 2, finalLabelOccupy], [finalLabelOccupy, edgeLength / 2]), 2), x = _g[0], y = _g[1];
|
|
282
|
+
return new BBox(x, y, width, height);
|
|
283
|
+
},
|
|
284
|
+
enumerable: false,
|
|
285
|
+
configurable: true
|
|
286
|
+
});
|
|
287
|
+
Object.defineProperty(Continuous.prototype, "ribbonShape", {
|
|
288
|
+
get: function () {
|
|
289
|
+
var _a = this.ribbonBBox, width = _a.width, height = _a.height;
|
|
290
|
+
return this.ifHorizontal({ size: height, length: width }, { size: width, length: height });
|
|
291
|
+
},
|
|
292
|
+
enumerable: false,
|
|
293
|
+
configurable: true
|
|
294
|
+
});
|
|
295
|
+
Continuous.prototype.renderRibbon = function (container) {
|
|
296
|
+
var _a = this.attributes, data = _a.data, type = _a.type, orientation = _a.orientation, color = _a.color, block = _a.block;
|
|
297
|
+
var ribbonStyle = subStyleProps(this.attributes, 'ribbon');
|
|
298
|
+
var _b = this.range, min = _b.min, max = _b.max;
|
|
299
|
+
var _c = this.ribbonBBox, x = _c.x, y = _c.y;
|
|
300
|
+
var _d = this.ribbonShape, length = _d.length, size = _d.size;
|
|
301
|
+
var style = deepAssign({
|
|
302
|
+
transform: "translate(".concat(x, ", ").concat(y, ")"),
|
|
303
|
+
length: length,
|
|
304
|
+
size: size,
|
|
305
|
+
type: type,
|
|
306
|
+
orientation: orientation,
|
|
307
|
+
color: color,
|
|
308
|
+
block: block,
|
|
309
|
+
partition: data.map(function (d) { return (d.value - min) / (max - min); }),
|
|
251
310
|
range: this.ribbonRange,
|
|
252
311
|
}, ribbonStyle);
|
|
253
|
-
this.ribbon = container.maybeAppendByClassName(CLASS_NAMES.ribbon, ()
|
|
254
|
-
}
|
|
255
|
-
getHandleClassName(type) {
|
|
312
|
+
this.ribbon = container.maybeAppendByClassName(CLASS_NAMES.ribbon, function () { return new Ribbon({ style: style }); }).update(style);
|
|
313
|
+
};
|
|
314
|
+
Continuous.prototype.getHandleClassName = function (type) {
|
|
256
315
|
// @ts-ignore
|
|
257
|
-
return
|
|
258
|
-
}
|
|
259
|
-
renderHandles() {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
316
|
+
return "".concat(CLASS_NAMES.prefix("".concat(type, "-handle")));
|
|
317
|
+
};
|
|
318
|
+
Continuous.prototype.renderHandles = function () {
|
|
319
|
+
var _a = this.attributes, showHandle = _a.showHandle, orientation = _a.orientation;
|
|
320
|
+
var handleStyle = subStyleProps(this.attributes, 'handle');
|
|
321
|
+
var _b = __read(this.selection, 2), min = _b[0], max = _b[1];
|
|
322
|
+
var style = __assign(__assign({}, handleStyle), { orientation: orientation });
|
|
323
|
+
var _c = handleStyle.shape, shape = _c === void 0 ? 'slider' : _c;
|
|
324
|
+
var HandleCtor = shape === 'basic' ? Handle : SliderHandle;
|
|
325
|
+
var that = this;
|
|
267
326
|
this.handlesGroup
|
|
268
327
|
.selectAll(CLASS_NAMES.handle.class)
|
|
269
328
|
.data(showHandle
|
|
@@ -271,202 +330,234 @@ export class Continuous extends Component {
|
|
|
271
330
|
{ value: min, type: 'start' },
|
|
272
331
|
{ value: max, type: 'end' },
|
|
273
332
|
]
|
|
274
|
-
: [], (d)
|
|
275
|
-
.join((enter)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
})
|
|
290
|
-
.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
333
|
+
: [], function (d) { return d.type; })
|
|
334
|
+
.join(function (enter) {
|
|
335
|
+
return enter
|
|
336
|
+
.append(function () { return new HandleCtor({ style: style }); })
|
|
337
|
+
.attr('className', function (_a) {
|
|
338
|
+
var type = _a.type;
|
|
339
|
+
return "".concat(CLASS_NAMES.handle, " ").concat(that.getHandleClassName(type));
|
|
340
|
+
})
|
|
341
|
+
.each(function (_a) {
|
|
342
|
+
var type = _a.type, labelText = _a.value;
|
|
343
|
+
this.update({ labelText: labelText });
|
|
344
|
+
var name = "".concat(type, "Handle");
|
|
345
|
+
that[name] = this;
|
|
346
|
+
this.addEventListener('pointerdown', that.onDragStart(type));
|
|
347
|
+
});
|
|
348
|
+
}, function (update) {
|
|
349
|
+
return update.update(style).each(function (_a) {
|
|
350
|
+
var labelText = _a.value;
|
|
351
|
+
this.update({ labelText: labelText });
|
|
352
|
+
});
|
|
353
|
+
}, function (exit) {
|
|
354
|
+
return exit
|
|
355
|
+
.each(function (_a) {
|
|
356
|
+
var type = _a.type;
|
|
357
|
+
var name = "".concat(type, "Handle");
|
|
358
|
+
that[name] = undefined;
|
|
359
|
+
})
|
|
360
|
+
.remove();
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
Continuous.prototype.adjustHandles = function () {
|
|
364
|
+
var _a = __read(this.selection, 2), min = _a[0], max = _a[1];
|
|
294
365
|
this.setHandlePosition('start', min);
|
|
295
366
|
this.setHandlePosition('end', max);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
367
|
+
};
|
|
368
|
+
Object.defineProperty(Continuous.prototype, "handleBBox", {
|
|
369
|
+
get: function () {
|
|
370
|
+
if (this.cacheHandleBBox)
|
|
371
|
+
return this.cacheHandleBBox;
|
|
372
|
+
if (!this.attributes.showHandle)
|
|
373
|
+
return new BBox(0, 0, 0, 0);
|
|
374
|
+
var _a = this.startHandle.getBBox(), startHandleWidth = _a.width, startHandleHeight = _a.height;
|
|
375
|
+
var _b = this.endHandle.getBBox(), endHandleWidth = _b.width, endHandleHeight = _b.height;
|
|
376
|
+
var _c = __read([Math.max(startHandleWidth, endHandleWidth), Math.max(startHandleHeight, endHandleHeight)], 2), width = _c[0], height = _c[1];
|
|
377
|
+
this.cacheHandleBBox = new BBox(0, 0, width, height);
|
|
299
378
|
return this.cacheHandleBBox;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
setHandlePosition(type, value) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
handle === null || handle === void 0 ? void 0 : handle.update({ transform:
|
|
324
|
-
}
|
|
325
|
-
renderIndicator(container) {
|
|
326
|
-
|
|
327
|
-
this.indicator = container.maybeAppendByClassName(CLASS_NAMES.indicator, ()
|
|
379
|
+
},
|
|
380
|
+
enumerable: false,
|
|
381
|
+
configurable: true
|
|
382
|
+
});
|
|
383
|
+
Object.defineProperty(Continuous.prototype, "handleShape", {
|
|
384
|
+
/**
|
|
385
|
+
* 因为 handle label 的宽高是动态的,所以 handle bbox 是第一次渲染时的 bbox
|
|
386
|
+
*/
|
|
387
|
+
get: function () {
|
|
388
|
+
var _a = this.handleBBox, width = _a.width, height = _a.height;
|
|
389
|
+
var _b = __read(this.ifHorizontal([height, width], [width, height]), 2), size = _b[0], length = _b[1];
|
|
390
|
+
return { width: width, height: height, size: size, length: length };
|
|
391
|
+
},
|
|
392
|
+
enumerable: false,
|
|
393
|
+
configurable: true
|
|
394
|
+
});
|
|
395
|
+
Continuous.prototype.setHandlePosition = function (type, value) {
|
|
396
|
+
var handleFormatter = this.attributes.handleFormatter;
|
|
397
|
+
var _a = this.ribbonBBox, ribbonX = _a.x, ribbonY = _a.y;
|
|
398
|
+
var ribbonSize = this.ribbonShape.size;
|
|
399
|
+
var offset = this.getOffset(value);
|
|
400
|
+
var _b = __read(this.ifHorizontal([ribbonX + offset, ribbonY + ribbonSize * this.handleOffsetRatio], [ribbonX + ribbonSize * this.handleOffsetRatio, ribbonY + offset]), 2), x = _b[0], y = _b[1];
|
|
401
|
+
var handle = this.handlesGroup.select(".".concat(this.getHandleClassName(type))).node();
|
|
402
|
+
handle === null || handle === void 0 ? void 0 : handle.update({ transform: "translate(".concat(x, ", ").concat(y, ")"), formatter: handleFormatter });
|
|
403
|
+
};
|
|
404
|
+
Continuous.prototype.renderIndicator = function (container) {
|
|
405
|
+
var style = subStyleProps(this.attributes, 'indicator');
|
|
406
|
+
this.indicator = container.maybeAppendByClassName(CLASS_NAMES.indicator, function () { return new Indicator({}); }).update(style);
|
|
328
407
|
// this.hideIndicator();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
index, type: 'range', range: [cr, nx], label: [cr, nx].join('~'), value:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
408
|
+
};
|
|
409
|
+
Object.defineProperty(Continuous.prototype, "labelData", {
|
|
410
|
+
get: function () {
|
|
411
|
+
var _this = this;
|
|
412
|
+
var data = this.attributes.data;
|
|
413
|
+
return data.reduce(function (acc, curr, index, arr) {
|
|
414
|
+
var _a, _b;
|
|
415
|
+
var id = (_a = curr === null || curr === void 0 ? void 0 : curr.id) !== null && _a !== void 0 ? _a : index.toString();
|
|
416
|
+
acc.push(__assign(__assign({}, curr), { id: id, index: index, type: 'value', label: (_b = curr === null || curr === void 0 ? void 0 : curr.label) !== null && _b !== void 0 ? _b : curr.value.toString(), value: _this.ribbonScale.map(curr.value) }));
|
|
417
|
+
if (index < arr.length - 1) {
|
|
418
|
+
var next = arr[index + 1];
|
|
419
|
+
var _c = __read([curr.value, next.value], 2), cr = _c[0], nx = _c[1];
|
|
420
|
+
var midVal = (cr + nx) / 2;
|
|
421
|
+
acc.push(__assign(__assign({}, curr), { id: id, index: index, type: 'range', range: [cr, nx], label: [cr, nx].join('~'), value: _this.ribbonScale.map(midVal) }));
|
|
422
|
+
}
|
|
423
|
+
return acc;
|
|
424
|
+
}, []);
|
|
425
|
+
},
|
|
426
|
+
enumerable: false,
|
|
427
|
+
configurable: true
|
|
428
|
+
});
|
|
429
|
+
Object.defineProperty(Continuous.prototype, "labelStyle", {
|
|
430
|
+
get: function () {
|
|
431
|
+
var _a = __read(['center', 'middle'], 2), labelTextAlign = _a[0], labelTextBaseline = _a[1];
|
|
432
|
+
var labelPosition = this.labelPosition;
|
|
433
|
+
if (labelPosition === 'top')
|
|
434
|
+
labelTextBaseline = 'bottom';
|
|
435
|
+
else if (labelPosition === 'bottom')
|
|
436
|
+
labelTextBaseline = 'top';
|
|
437
|
+
else if (labelPosition === 'left')
|
|
438
|
+
labelTextAlign = 'end';
|
|
439
|
+
else if (labelPosition === 'right')
|
|
440
|
+
labelTextAlign = 'start';
|
|
441
|
+
return {
|
|
442
|
+
labelTextAlign: labelTextAlign,
|
|
443
|
+
labelTextBaseline: labelTextBaseline,
|
|
444
|
+
};
|
|
445
|
+
},
|
|
446
|
+
enumerable: false,
|
|
447
|
+
configurable: true
|
|
448
|
+
});
|
|
449
|
+
Continuous.prototype.renderLabel = function (container) {
|
|
450
|
+
var _a = this.attributes, _b = _a.showTick, showTick = _b === void 0 ? false : _b, labelFilter = _a.labelFilter, labelFormatter = _a.labelFormatter;
|
|
451
|
+
var tickStyle = subStyleProps(this.attributes, 'tick');
|
|
452
|
+
var labelStyle = subStyleProps(this.attributes, 'label');
|
|
453
|
+
var align = labelStyle.align;
|
|
454
|
+
var style = deepAssign(__assign({ showLine: false, showGrid: false, showTick: showTick, type: 'linear', startPos: [0, 0], endPos: [0, 0], tickDirection: 'negative', labelTransform: 'rotate(0)' }, this.labelStyle), superStyleProps(tickStyle, 'tick'), superStyleProps(labelStyle, 'label'), { data: this.labelData });
|
|
455
|
+
var functionStyle = {
|
|
456
|
+
tickFilter: function (datum, index, data) {
|
|
371
457
|
if ((datum === null || datum === void 0 ? void 0 : datum.type) !== 'value')
|
|
372
458
|
return false;
|
|
373
459
|
if (labelFilter)
|
|
374
|
-
return labelFilter(datum, datum.index, data.filter((d)
|
|
460
|
+
return labelFilter(datum, datum.index, data.filter(function (d) { return d.type !== 'value'; }));
|
|
375
461
|
return true;
|
|
376
462
|
},
|
|
377
|
-
labelFilter: (datum, index, data)
|
|
463
|
+
labelFilter: function (datum, index, data) {
|
|
378
464
|
if ((datum === null || datum === void 0 ? void 0 : datum.type) !== align)
|
|
379
465
|
return false;
|
|
380
466
|
if (labelFilter)
|
|
381
|
-
return labelFilter(datum, datum.index, data.filter((d)
|
|
467
|
+
return labelFilter(datum, datum.index, data.filter(function (d) { return d.type === align; }));
|
|
382
468
|
return true;
|
|
383
469
|
},
|
|
384
|
-
labelFormatter,
|
|
470
|
+
labelFormatter: labelFormatter,
|
|
385
471
|
};
|
|
386
|
-
|
|
387
|
-
this.label = container.maybeAppendByClassName(CLASS_NAMES.label, ()
|
|
472
|
+
var finalLabelStyle = __assign(__assign(__assign({}, style), functionStyle), { labelOverlap: [{ type: 'hide' }] });
|
|
473
|
+
this.label = container.maybeAppendByClassName(CLASS_NAMES.label, function () { return new Axis({ style: finalLabelStyle }); }).node();
|
|
388
474
|
this.label.update(finalLabelStyle, false);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (
|
|
403
|
-
|
|
404
|
-
|
|
475
|
+
};
|
|
476
|
+
Object.defineProperty(Continuous.prototype, "labelAxisStyle", {
|
|
477
|
+
get: function () {
|
|
478
|
+
// @ts-ignore
|
|
479
|
+
var _a = this.attributes, showTick = _a.showTick, labelDirection = _a.labelDirection, labelSpacing = _a.labelSpacing, definedTickLength = _a.tickLength;
|
|
480
|
+
var ribbonSize = this.ribbonShape.size;
|
|
481
|
+
var labelPosition = this.labelPosition;
|
|
482
|
+
var labelFixedSpacing = this.labelFixedSpacing;
|
|
483
|
+
var _b = __read([0, 0, 0], 3), offset = _b[0], spacing = _b[1], tickLength = _b[2];
|
|
484
|
+
var internalVal = definedTickLength !== null && definedTickLength !== void 0 ? definedTickLength : ribbonSize;
|
|
485
|
+
if (showTick) {
|
|
486
|
+
tickLength = internalVal;
|
|
487
|
+
spacing = labelFixedSpacing;
|
|
488
|
+
if (labelDirection === 'positive') {
|
|
489
|
+
if (labelPosition === 'right') {
|
|
490
|
+
offset = internalVal;
|
|
491
|
+
tickLength = internalVal;
|
|
492
|
+
}
|
|
493
|
+
else if (labelPosition === 'bottom')
|
|
494
|
+
offset = tickLength;
|
|
495
|
+
}
|
|
496
|
+
else if (labelDirection === 'negative') {
|
|
497
|
+
if (labelPosition === 'top')
|
|
498
|
+
offset = ribbonSize;
|
|
499
|
+
else if (labelPosition === 'left')
|
|
500
|
+
offset = ribbonSize;
|
|
405
501
|
}
|
|
406
|
-
else if (labelPosition === 'bottom')
|
|
407
|
-
offset = tickLength;
|
|
408
502
|
}
|
|
409
|
-
else if (labelDirection === '
|
|
410
|
-
if (labelPosition === '
|
|
411
|
-
|
|
412
|
-
else if (labelPosition === '
|
|
413
|
-
offset = ribbonSize;
|
|
503
|
+
else if (labelDirection === 'positive') {
|
|
504
|
+
if (labelPosition === 'right')
|
|
505
|
+
spacing = internalVal;
|
|
506
|
+
else if (labelPosition === 'bottom') {
|
|
507
|
+
offset = ribbonSize + labelFixedSpacing;
|
|
508
|
+
spacing = labelSpacing;
|
|
509
|
+
}
|
|
414
510
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
offset = ribbonSize + labelFixedSpacing;
|
|
421
|
-
spacing = labelSpacing;
|
|
511
|
+
else if (labelDirection === 'negative') {
|
|
512
|
+
if (labelPosition === 'left')
|
|
513
|
+
spacing = labelSpacing;
|
|
514
|
+
else if (labelPosition === 'top')
|
|
515
|
+
spacing = labelSpacing;
|
|
422
516
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return { offset, spacing, tickLength };
|
|
431
|
-
}
|
|
432
|
-
adjustLabel() {
|
|
433
|
-
const { showLabel } = this.attributes;
|
|
517
|
+
return { offset: offset, spacing: spacing, tickLength: tickLength };
|
|
518
|
+
},
|
|
519
|
+
enumerable: false,
|
|
520
|
+
configurable: true
|
|
521
|
+
});
|
|
522
|
+
Continuous.prototype.adjustLabel = function () {
|
|
523
|
+
var showLabel = this.attributes.showLabel;
|
|
434
524
|
if (!showLabel)
|
|
435
525
|
return;
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
526
|
+
var _a = this.ribbonBBox, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
527
|
+
var _b = this.labelAxisStyle, axisOffset = _b.offset, axisSpacing = _b.spacing, axisTickLength = _b.tickLength;
|
|
528
|
+
var _c = __read(this.ifHorizontal([
|
|
439
529
|
[x, y + axisOffset],
|
|
440
530
|
[x + width, y + axisOffset],
|
|
441
531
|
], [
|
|
442
532
|
[x + axisOffset, y + height],
|
|
443
533
|
[x + axisOffset, y],
|
|
444
|
-
]);
|
|
534
|
+
]), 2), startPos = _c[0], endPos = _c[1];
|
|
445
535
|
this.label.update({
|
|
446
|
-
startPos,
|
|
447
|
-
endPos,
|
|
536
|
+
startPos: startPos,
|
|
537
|
+
endPos: endPos,
|
|
448
538
|
tickLength: axisTickLength,
|
|
449
539
|
labelSpacing: axisSpacing,
|
|
450
540
|
}, false);
|
|
451
|
-
}
|
|
452
|
-
bindEvents() {
|
|
541
|
+
};
|
|
542
|
+
Continuous.prototype.bindEvents = function () {
|
|
453
543
|
this.style.cursor = 'pointer';
|
|
454
544
|
// 绑定 drag 开始事件
|
|
455
545
|
this.ribbon.on('pointerdown', this.onDragStart('ribbon'));
|
|
456
546
|
this.ribbon.on('pointermove', this.onHovering);
|
|
457
547
|
this.addEventListener('pointerout', this.hideIndicator);
|
|
458
|
-
}
|
|
459
|
-
showIndicator(value, text
|
|
460
|
-
|
|
548
|
+
};
|
|
549
|
+
Continuous.prototype.showIndicator = function (value, text) {
|
|
550
|
+
if (text === void 0) { text = "".concat(value); }
|
|
551
|
+
var showIndicator = this.attributes.showIndicator;
|
|
461
552
|
if (!showIndicator || typeof value !== 'number') {
|
|
462
553
|
this.hideIndicator();
|
|
463
554
|
return;
|
|
464
555
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
556
|
+
var _a = this.range, min = _a.min, max = _a.max;
|
|
557
|
+
var _b = this.ribbonBBox, x = _b.x, y = _b.y;
|
|
558
|
+
var safeValue = clamp(value, min, max);
|
|
559
|
+
var offset = this.getOffset(safeValue);
|
|
560
|
+
var pos = this.ifHorizontal([offset + x, y], [x, offset + y]);
|
|
470
561
|
this.indicator.update({
|
|
471
562
|
x: pos[0],
|
|
472
563
|
y: pos[1],
|
|
@@ -474,102 +565,115 @@ export class Continuous extends Component {
|
|
|
474
565
|
labelText: text,
|
|
475
566
|
});
|
|
476
567
|
show(this.indicator.node());
|
|
477
|
-
}
|
|
478
|
-
hideIndicator() {
|
|
568
|
+
};
|
|
569
|
+
Continuous.prototype.hideIndicator = function () {
|
|
479
570
|
hide(this.indicator.node());
|
|
480
|
-
}
|
|
481
|
-
updateMouse() {
|
|
571
|
+
};
|
|
572
|
+
Continuous.prototype.updateMouse = function () {
|
|
482
573
|
if (this.attributes.slidable)
|
|
483
574
|
this.style.cursor = 'grabbing';
|
|
484
|
-
}
|
|
485
|
-
setSelection(start, end) {
|
|
575
|
+
};
|
|
576
|
+
Continuous.prototype.setSelection = function (start, end) {
|
|
486
577
|
this.updateSelection(start, end);
|
|
487
|
-
}
|
|
488
|
-
updateSelection(stVal, endVal, isOffset
|
|
489
|
-
|
|
490
|
-
|
|
578
|
+
};
|
|
579
|
+
Continuous.prototype.updateSelection = function (stVal, endVal, isOffset) {
|
|
580
|
+
var _a;
|
|
581
|
+
if (isOffset === void 0) { isOffset = false; }
|
|
582
|
+
var _b = __read(this.selection, 2), currSt = _b[0], currEnd = _b[1];
|
|
583
|
+
var _c = __read([stVal, endVal], 2), start = _c[0], end = _c[1];
|
|
491
584
|
if (isOffset) {
|
|
492
585
|
// 获取当前值
|
|
493
586
|
start += currSt;
|
|
494
587
|
end += currEnd;
|
|
495
588
|
}
|
|
496
589
|
// 值校验
|
|
497
|
-
|
|
498
|
-
|
|
590
|
+
var _d = this.range, min = _d.min, max = _d.max;
|
|
591
|
+
_a = __read(getSafetySelections([min, max], [start, end], this.selection), 2), start = _a[0], end = _a[1];
|
|
499
592
|
this.update({ defaultValue: [start, end] });
|
|
500
593
|
this.dispatchSelection();
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
594
|
+
};
|
|
595
|
+
Object.defineProperty(Continuous.prototype, "step", {
|
|
596
|
+
get: function () {
|
|
597
|
+
var _a = this.attributes.step, step = _a === void 0 ? 1 : _a;
|
|
598
|
+
var _b = this.range, min = _b.min, max = _b.max;
|
|
599
|
+
if (isUndefined(step))
|
|
600
|
+
return toPrecision((max - min) * STEP_RATIO, 0);
|
|
601
|
+
return step;
|
|
602
|
+
},
|
|
603
|
+
enumerable: false,
|
|
604
|
+
configurable: true
|
|
605
|
+
});
|
|
606
|
+
Continuous.prototype.getTickValue = function (value) {
|
|
607
|
+
var _a = this.attributes, data = _a.data, block = _a.block;
|
|
608
|
+
var min = this.range.min;
|
|
512
609
|
if (block)
|
|
513
|
-
return getNextTickValue(data.map((
|
|
610
|
+
return getNextTickValue(data.map(function (_a) {
|
|
611
|
+
var value = _a.value;
|
|
612
|
+
return value;
|
|
613
|
+
}), value).tick;
|
|
514
614
|
return getStepValueByValue(value, this.step, min);
|
|
515
|
-
}
|
|
615
|
+
};
|
|
516
616
|
/**
|
|
517
617
|
* 事件触发的位置对应的value值
|
|
518
618
|
*/
|
|
519
|
-
getValueByCanvasPoint(e) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
619
|
+
Continuous.prototype.getValueByCanvasPoint = function (e) {
|
|
620
|
+
var _a = this.range, min = _a.min, max = _a.max;
|
|
621
|
+
var _b = __read(this.ribbon.node().getPosition(), 2), x = _b[0], y = _b[1];
|
|
622
|
+
var startPos = this.ifHorizontal(x, y);
|
|
623
|
+
var currValue = this.ifHorizontal.apply(this, __spreadArray([], __read(getEventPos(e)), false));
|
|
624
|
+
var offset = currValue - startPos;
|
|
625
|
+
var value = clamp(this.getOffset(offset, true), min, max);
|
|
526
626
|
return value;
|
|
527
|
-
}
|
|
627
|
+
};
|
|
528
628
|
/** reverse: 屏幕偏移量 -> 值 */
|
|
529
|
-
getOffset(value, reverse
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
629
|
+
Continuous.prototype.getOffset = function (value, reverse) {
|
|
630
|
+
if (reverse === void 0) { reverse = false; }
|
|
631
|
+
var _a = this.range, min = _a.min, max = _a.max;
|
|
632
|
+
var ribbonLen = this.ribbonShape.length;
|
|
633
|
+
var scale = this.eventToOffsetScale;
|
|
533
634
|
scale.update({ domain: [min, max], range: [0, ribbonLen] });
|
|
534
635
|
if (reverse)
|
|
535
636
|
return scale.invert(value);
|
|
536
637
|
return scale.map(value);
|
|
537
|
-
}
|
|
538
|
-
getRealSelection(range) {
|
|
539
|
-
|
|
540
|
-
|
|
638
|
+
};
|
|
639
|
+
Continuous.prototype.getRealSelection = function (range) {
|
|
640
|
+
var max = this.range.max;
|
|
641
|
+
var _a = __read(range, 2), start = _a[0], end = _a[1];
|
|
541
642
|
return this.ifHorizontal([start, end], [max - end, max - start]);
|
|
542
|
-
}
|
|
543
|
-
getRealValue(value) {
|
|
544
|
-
|
|
643
|
+
};
|
|
644
|
+
Continuous.prototype.getRealValue = function (value) {
|
|
645
|
+
var max = this.range.max;
|
|
545
646
|
return this.ifHorizontal(value, max - value);
|
|
546
|
-
}
|
|
547
|
-
dispatchSelection() {
|
|
548
|
-
|
|
549
|
-
|
|
647
|
+
};
|
|
648
|
+
Continuous.prototype.dispatchSelection = function () {
|
|
649
|
+
var selection = this.getRealSelection(this.selection);
|
|
650
|
+
var evt = new CustomEvent('valuechange', {
|
|
550
651
|
detail: {
|
|
551
652
|
value: selection,
|
|
552
653
|
},
|
|
553
654
|
});
|
|
554
655
|
this.dispatchEvent(evt);
|
|
555
|
-
}
|
|
556
|
-
dispatchIndicated(value, range) {
|
|
557
|
-
|
|
558
|
-
|
|
656
|
+
};
|
|
657
|
+
Continuous.prototype.dispatchIndicated = function (value, range) {
|
|
658
|
+
var _this = this;
|
|
659
|
+
var max = this.range.max;
|
|
660
|
+
var detail = this.ifHorizontal(function () {
|
|
559
661
|
return {
|
|
560
|
-
value,
|
|
561
|
-
range,
|
|
662
|
+
value: value,
|
|
663
|
+
range: range,
|
|
562
664
|
};
|
|
563
|
-
}, ()
|
|
665
|
+
}, function () {
|
|
564
666
|
return {
|
|
565
667
|
value: max - value,
|
|
566
|
-
range: range ?
|
|
668
|
+
range: range ? _this.getRealSelection(range) : undefined,
|
|
567
669
|
};
|
|
568
670
|
});
|
|
569
|
-
|
|
570
|
-
detail,
|
|
671
|
+
var evt = new CustomEvent('indicate', {
|
|
672
|
+
detail: detail,
|
|
571
673
|
});
|
|
572
674
|
this.dispatchEvent(evt);
|
|
573
|
-
}
|
|
574
|
-
|
|
675
|
+
};
|
|
676
|
+
return Continuous;
|
|
677
|
+
}(Component));
|
|
678
|
+
export { Continuous };
|
|
575
679
|
//# sourceMappingURL=continuous.js.map
|