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