@antv/g2 5.0.0-beta.4 → 5.0.0-beta.6
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/g2-lite.min.js +5 -2
- package/dist/g2.min.js +5 -2
- package/esm/api/chart.d.ts +4 -0
- package/esm/api/chart.js +26 -4
- package/esm/api/chart.js.map +1 -1
- package/esm/api/mark/mark.js +1 -2
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -2
- package/esm/component/axis.js +23 -9
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +2 -0
- package/esm/component/index.js +2 -0
- package/esm/component/index.js.map +1 -1
- package/esm/component/scrollbar.d.ts +9 -0
- package/esm/component/scrollbar.js +36 -0
- package/esm/component/scrollbar.js.map +1 -0
- package/esm/component/scrollbarX.d.ts +7 -0
- package/esm/component/scrollbarX.js +9 -0
- package/esm/component/scrollbarX.js.map +1 -0
- package/esm/component/scrollbarY.d.ts +7 -0
- package/esm/component/scrollbarY.js +9 -0
- package/esm/component/scrollbarY.js.map +1 -0
- package/esm/component/slider.js +2 -4
- package/esm/component/slider.js.map +1 -1
- package/esm/component/title.js +46 -22
- package/esm/component/title.js.map +1 -1
- package/esm/composition/mark.js +2 -1
- package/esm/composition/mark.js.map +1 -1
- package/esm/data/fold.js +4 -10
- package/esm/data/fold.js.map +1 -1
- package/esm/data/index.d.ts +2 -2
- package/esm/data/index.js +1 -1
- package/esm/data/index.js.map +1 -1
- package/esm/data/pick.js +10 -2
- package/esm/data/pick.js.map +1 -1
- package/esm/data/slice.d.ts +8 -0
- package/esm/data/slice.js +10 -0
- package/esm/data/slice.js.map +1 -0
- package/esm/interaction/builtin/brushHighlight.d.ts +1 -1
- package/esm/interaction/index.d.ts +8 -0
- package/esm/interaction/index.js +7 -30
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/esm/interaction/native/brushAxisHighlight.js +159 -0
- package/esm/interaction/native/brushAxisHighlight.js.map +1 -0
- package/esm/interaction/native/brushFilter.d.ts +12 -0
- package/esm/interaction/native/brushFilter.js +147 -0
- package/esm/interaction/native/brushFilter.js.map +1 -0
- package/esm/interaction/native/brushHighlight.d.ts +40 -0
- package/esm/interaction/native/brushHighlight.js +341 -0
- package/esm/interaction/native/brushHighlight.js.map +1 -0
- package/esm/interaction/native/brushXFilter.d.ts +1 -0
- package/esm/interaction/native/brushXFilter.js +6 -0
- package/esm/interaction/native/brushXFilter.js.map +1 -0
- package/esm/interaction/native/brushXHighlight.d.ts +6 -0
- package/esm/interaction/native/brushXHighlight.js +9 -0
- package/esm/interaction/native/brushXHighlight.js.map +1 -0
- package/esm/interaction/native/brushYFilter.d.ts +1 -0
- package/esm/interaction/native/brushYFilter.js +6 -0
- package/esm/interaction/native/brushYFilter.js.map +1 -0
- package/esm/interaction/native/brushYHighlight.d.ts +6 -0
- package/esm/interaction/native/brushYHighlight.js +9 -0
- package/esm/interaction/native/brushYHighlight.js.map +1 -0
- package/esm/interaction/native/legendFilter.js +3 -12
- package/esm/interaction/native/legendFilter.js.map +1 -1
- package/esm/interaction/native/tooltip.js +101 -32
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/interaction/native/utils.d.ts +8 -0
- package/esm/interaction/native/utils.js +31 -0
- package/esm/interaction/native/utils.js.map +1 -1
- package/esm/label-transform/contrastReverse.d.ts +9 -0
- package/esm/label-transform/contrastReverse.js +48 -0
- package/esm/label-transform/contrastReverse.js.map +1 -0
- package/esm/label-transform/index.d.ts +8 -8
- package/esm/label-transform/index.js +4 -4
- package/esm/label-transform/index.js.map +1 -1
- package/esm/label-transform/overflowHide.d.ts +7 -0
- package/esm/label-transform/overflowHide.js +18 -0
- package/esm/label-transform/overflowHide.js.map +1 -0
- package/esm/label-transform/overlapDodgeY.d.ts +7 -0
- package/esm/label-transform/{dodgeY.js → overlapDodgeY.js} +4 -4
- package/esm/label-transform/overlapDodgeY.js.map +1 -0
- package/esm/label-transform/overlapHide.d.ts +7 -0
- package/esm/label-transform/overlapHide.js +24 -0
- package/esm/label-transform/overlapHide.js.map +1 -0
- package/esm/mark/area.js +1 -1
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/boxplot.js +5 -18
- package/esm/mark/boxplot.js.map +1 -1
- package/esm/runtime/component.js +33 -38
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +7 -7
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +28 -6
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.d.ts +0 -1
- package/esm/runtime/render.js +4 -34
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/scale.js +17 -5
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +16 -6
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +27 -9
- package/esm/runtime/types/options.d.ts +3 -5
- package/esm/runtime/types/theme.d.ts +2 -5
- package/esm/shape/area/curve.js +15 -8
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/box/box.js +1 -1
- package/esm/shape/box/box.js.map +1 -1
- package/esm/shape/connector/connector.js +2 -2
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/image/image.js +2 -2
- package/esm/shape/image/image.js.map +1 -1
- package/esm/shape/interval/color.js +3 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/label/label.js +3 -3
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/label/position/area.d.ts +13 -0
- package/esm/shape/label/position/area.js +28 -0
- package/esm/shape/label/position/area.js.map +1 -0
- package/esm/shape/label/position/bottom.d.ts +1 -0
- package/esm/shape/label/position/bottom.js +2 -0
- package/esm/shape/label/position/bottom.js.map +1 -0
- package/esm/shape/label/position/bottomLeft.d.ts +1 -0
- package/esm/shape/label/position/bottomLeft.js +2 -0
- package/esm/shape/label/position/bottomLeft.js.map +1 -0
- package/esm/shape/label/position/bottomRight.d.ts +1 -0
- package/esm/shape/label/position/bottomRight.js +2 -0
- package/esm/shape/label/position/bottomRight.js.map +1 -0
- package/esm/shape/label/position/default.d.ts +18 -0
- package/esm/shape/label/position/default.js +107 -0
- package/esm/shape/label/position/default.js.map +1 -0
- package/esm/shape/label/position/index.d.ts +13 -0
- package/esm/shape/label/position/index.js +14 -0
- package/esm/shape/label/position/index.js.map +1 -0
- package/esm/shape/label/position/inside.d.ts +1 -0
- package/esm/shape/label/position/inside.js +2 -0
- package/esm/shape/label/position/inside.js.map +1 -0
- package/esm/shape/label/position/left.d.ts +1 -0
- package/esm/shape/label/position/left.js +2 -0
- package/esm/shape/label/position/left.js.map +1 -0
- package/esm/shape/label/position/outside.d.ts +18 -0
- package/esm/shape/label/position/outside.js +67 -0
- package/esm/shape/label/position/outside.js.map +1 -0
- package/esm/shape/label/position/right.d.ts +1 -0
- package/esm/shape/label/position/right.js +2 -0
- package/esm/shape/label/position/right.js.map +1 -0
- package/esm/shape/label/position/spider.d.ts +7 -0
- package/esm/shape/label/position/spider.js +34 -0
- package/esm/shape/label/position/spider.js.map +1 -0
- package/esm/shape/label/position/surround.d.ts +7 -0
- package/esm/shape/label/position/surround.js +35 -0
- package/esm/shape/label/position/surround.js.map +1 -0
- package/esm/shape/label/position/top.d.ts +1 -0
- package/esm/shape/label/position/top.js +2 -0
- package/esm/shape/label/position/top.js.map +1 -0
- package/esm/shape/label/position/topLeft.d.ts +1 -0
- package/esm/shape/label/position/topLeft.js +2 -0
- package/esm/shape/label/position/topLeft.js.map +1 -0
- package/esm/shape/label/position/topRight.d.ts +1 -0
- package/esm/shape/label/position/topRight.js +2 -0
- package/esm/shape/label/position/topRight.js.map +1 -0
- package/esm/shape/line/curve.js +1 -1
- package/esm/shape/line/curve.js.map +1 -1
- package/esm/shape/lineXY/line.js +2 -2
- package/esm/shape/lineXY/line.js.map +1 -1
- package/esm/shape/link/arc.js +2 -2
- package/esm/shape/link/arc.js.map +1 -1
- package/esm/shape/link/link.js +2 -2
- package/esm/shape/link/link.js.map +1 -1
- package/esm/shape/link/smooth.js +2 -2
- package/esm/shape/link/smooth.js.map +1 -1
- package/esm/shape/link/vhv.js +2 -2
- package/esm/shape/link/vhv.js.map +1 -1
- package/esm/shape/point/color.js +1 -1
- package/esm/shape/point/color.js.map +1 -1
- package/esm/shape/polygon/polygon.js +3 -3
- package/esm/shape/polygon/polygon.js.map +1 -1
- package/esm/shape/polygon/ribbon.js +3 -3
- package/esm/shape/polygon/ribbon.js.map +1 -1
- package/esm/shape/text/advance.js +1 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/badge.js +3 -3
- package/esm/shape/text/badge.js.map +1 -1
- package/esm/shape/text/text.js +1 -1
- package/esm/shape/text/text.js.map +1 -1
- package/esm/shape/utils.d.ts +4 -0
- package/esm/shape/utils.js +6 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/shape/vector/vector.js +3 -3
- package/esm/shape/vector/vector.js.map +1 -1
- package/esm/spec/composition.d.ts +2 -0
- package/esm/spec/data.d.ts +24 -9
- package/esm/spec/geometry.d.ts +2 -1
- package/esm/spec/interaction.d.ts +41 -6
- package/esm/spec/labelTransform.d.ts +24 -11
- package/esm/spec/theme.d.ts +5 -2
- package/esm/stdlib/index.js +8 -9
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.d.ts +3 -0
- package/esm/theme/academy.js +398 -0
- package/esm/theme/academy.js.map +1 -0
- package/esm/theme/dark.js +14 -20
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/index.d.ts +1 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/index.js.map +1 -1
- package/esm/theme/light.js +29 -22
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/maybeTooltip.js +3 -1
- package/esm/transform/maybeTooltip.js.map +1 -1
- package/esm/utils/bounds.d.ts +26 -0
- package/esm/utils/bounds.js +41 -0
- package/esm/utils/bounds.js.map +1 -0
- package/esm/utils/color.d.ts +6 -0
- package/esm/utils/color.js +7 -0
- package/esm/utils/color.js.map +1 -0
- package/esm/utils/coordinate.d.ts +1 -0
- package/esm/utils/coordinate.js +12 -0
- package/esm/utils/coordinate.js.map +1 -1
- package/esm/utils/helper.d.ts +1 -0
- package/esm/utils/helper.js +3 -0
- package/esm/utils/helper.js.map +1 -1
- package/lib/api/chart.d.ts +4 -0
- package/lib/api/chart.js +26 -4
- package/lib/api/chart.js.map +1 -1
- package/lib/api/mark/mark.js +1 -2
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -2
- package/lib/component/axis.js +23 -9
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +2 -0
- package/lib/component/index.js +5 -1
- package/lib/component/index.js.map +1 -1
- package/lib/component/scrollbar.d.ts +9 -0
- package/lib/component/scrollbar.js +40 -0
- package/lib/component/scrollbar.js.map +1 -0
- package/lib/component/scrollbarX.d.ts +7 -0
- package/lib/component/scrollbarX.js +13 -0
- package/lib/component/scrollbarX.js.map +1 -0
- package/lib/component/scrollbarY.d.ts +7 -0
- package/lib/component/scrollbarY.js +13 -0
- package/lib/component/scrollbarY.js.map +1 -0
- package/lib/component/slider.js +2 -4
- package/lib/component/slider.js.map +1 -1
- package/lib/component/title.js +46 -22
- package/lib/component/title.js.map +1 -1
- package/lib/composition/mark.js +2 -1
- package/lib/composition/mark.js.map +1 -1
- package/lib/data/fold.js +4 -10
- package/lib/data/fold.js.map +1 -1
- package/lib/data/index.d.ts +2 -2
- package/lib/data/index.js +3 -3
- package/lib/data/index.js.map +1 -1
- package/lib/data/pick.js +10 -2
- package/lib/data/pick.js.map +1 -1
- package/lib/data/slice.d.ts +8 -0
- package/lib/data/slice.js +14 -0
- package/lib/data/slice.js.map +1 -0
- package/lib/interaction/builtin/brushHighlight.d.ts +1 -1
- package/lib/interaction/index.d.ts +8 -0
- package/lib/interaction/index.js +15 -31
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/lib/interaction/native/brushAxisHighlight.js +164 -0
- package/lib/interaction/native/brushAxisHighlight.js.map +1 -0
- package/lib/interaction/native/brushFilter.d.ts +12 -0
- package/lib/interaction/native/brushFilter.js +152 -0
- package/lib/interaction/native/brushFilter.js.map +1 -0
- package/lib/interaction/native/brushHighlight.d.ts +40 -0
- package/lib/interaction/native/brushHighlight.js +347 -0
- package/lib/interaction/native/brushHighlight.js.map +1 -0
- package/lib/interaction/native/brushXFilter.d.ts +1 -0
- package/lib/interaction/native/brushXFilter.js +10 -0
- package/lib/interaction/native/brushXFilter.js.map +1 -0
- package/lib/interaction/native/brushXHighlight.d.ts +6 -0
- package/lib/interaction/native/brushXHighlight.js +14 -0
- package/lib/interaction/native/brushXHighlight.js.map +1 -0
- package/lib/interaction/native/brushYFilter.d.ts +1 -0
- package/lib/interaction/native/brushYFilter.js +10 -0
- package/lib/interaction/native/brushYFilter.js.map +1 -0
- package/lib/interaction/native/brushYHighlight.d.ts +6 -0
- package/lib/interaction/native/brushYHighlight.js +14 -0
- package/lib/interaction/native/brushYHighlight.js.map +1 -0
- package/lib/interaction/native/legendFilter.js +4 -13
- package/lib/interaction/native/legendFilter.js.map +1 -1
- package/lib/interaction/native/tooltip.js +98 -29
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/interaction/native/utils.d.ts +8 -0
- package/lib/interaction/native/utils.js +37 -1
- package/lib/interaction/native/utils.js.map +1 -1
- package/lib/label-transform/contrastReverse.d.ts +9 -0
- package/lib/label-transform/contrastReverse.js +52 -0
- package/lib/label-transform/contrastReverse.js.map +1 -0
- package/lib/label-transform/index.d.ts +8 -8
- package/lib/label-transform/index.js +9 -9
- package/lib/label-transform/index.js.map +1 -1
- package/lib/label-transform/overflowHide.d.ts +7 -0
- package/lib/label-transform/overflowHide.js +22 -0
- package/lib/label-transform/overflowHide.js.map +1 -0
- package/lib/label-transform/overlapDodgeY.d.ts +7 -0
- package/lib/label-transform/{dodgeY.js → overlapDodgeY.js} +6 -6
- package/lib/label-transform/overlapDodgeY.js.map +1 -0
- package/lib/label-transform/overlapHide.d.ts +7 -0
- package/lib/label-transform/overlapHide.js +28 -0
- package/lib/label-transform/overlapHide.js.map +1 -0
- package/lib/mark/area.js +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/boxplot.js +5 -18
- package/lib/mark/boxplot.js.map +1 -1
- package/lib/runtime/component.js +33 -38
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +7 -7
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +28 -6
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.d.ts +0 -1
- package/lib/runtime/render.js +4 -35
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/scale.js +16 -4
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +16 -6
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +27 -9
- package/lib/runtime/types/options.d.ts +3 -5
- package/lib/runtime/types/theme.d.ts +2 -5
- package/lib/shape/area/curve.js +14 -7
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/box/box.js +1 -1
- package/lib/shape/box/box.js.map +1 -1
- package/lib/shape/connector/connector.js +2 -2
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/image/image.js +2 -2
- package/lib/shape/image/image.js.map +1 -1
- package/lib/shape/interval/color.js +3 -1
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/label/label.js +3 -3
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/label/position/area.d.ts +13 -0
- package/lib/shape/label/position/area.js +32 -0
- package/lib/shape/label/position/area.js.map +1 -0
- package/lib/shape/label/position/bottom.d.ts +1 -0
- package/lib/shape/label/position/bottom.js +6 -0
- package/lib/shape/label/position/bottom.js.map +1 -0
- package/lib/shape/label/position/bottomLeft.d.ts +1 -0
- package/lib/shape/label/position/bottomLeft.js +6 -0
- package/lib/shape/label/position/bottomLeft.js.map +1 -0
- package/lib/shape/label/position/bottomRight.d.ts +1 -0
- package/lib/shape/label/position/bottomRight.js +6 -0
- package/lib/shape/label/position/bottomRight.js.map +1 -0
- package/lib/shape/label/position/default.d.ts +18 -0
- package/lib/shape/label/{position.js → position/default.js} +24 -81
- package/lib/shape/label/position/default.js.map +1 -0
- package/lib/shape/label/position/index.d.ts +13 -0
- package/lib/shape/label/position/index.js +30 -0
- package/lib/shape/label/position/index.js.map +1 -0
- package/lib/shape/label/position/inside.d.ts +1 -0
- package/lib/shape/label/position/inside.js +6 -0
- package/lib/shape/label/position/inside.js.map +1 -0
- package/lib/shape/label/position/left.d.ts +1 -0
- package/lib/shape/label/position/left.js +6 -0
- package/lib/shape/label/position/left.js.map +1 -0
- package/lib/shape/label/position/outside.d.ts +18 -0
- package/lib/shape/label/position/outside.js +75 -0
- package/lib/shape/label/position/outside.js.map +1 -0
- package/lib/shape/label/position/right.d.ts +1 -0
- package/lib/shape/label/position/right.js +6 -0
- package/lib/shape/label/position/right.js.map +1 -0
- package/lib/shape/label/position/spider.d.ts +7 -0
- package/lib/shape/label/position/spider.js +38 -0
- package/lib/shape/label/position/spider.js.map +1 -0
- package/lib/shape/label/position/surround.d.ts +7 -0
- package/lib/shape/label/position/surround.js +39 -0
- package/lib/shape/label/position/surround.js.map +1 -0
- package/lib/shape/label/position/top.d.ts +1 -0
- package/lib/shape/label/position/top.js +6 -0
- package/lib/shape/label/position/top.js.map +1 -0
- package/lib/shape/label/position/topLeft.d.ts +1 -0
- package/lib/shape/label/position/topLeft.js +6 -0
- package/lib/shape/label/position/topLeft.js.map +1 -0
- package/lib/shape/label/position/topRight.d.ts +1 -0
- package/lib/shape/label/position/topRight.js +6 -0
- package/lib/shape/label/position/topRight.js.map +1 -0
- package/lib/shape/line/curve.js +1 -1
- package/lib/shape/line/curve.js.map +1 -1
- package/lib/shape/lineXY/line.js +2 -2
- package/lib/shape/lineXY/line.js.map +1 -1
- package/lib/shape/link/arc.js +2 -2
- package/lib/shape/link/arc.js.map +1 -1
- package/lib/shape/link/link.js +2 -2
- package/lib/shape/link/link.js.map +1 -1
- package/lib/shape/link/smooth.js +2 -2
- package/lib/shape/link/smooth.js.map +1 -1
- package/lib/shape/link/vhv.js +2 -2
- package/lib/shape/link/vhv.js.map +1 -1
- package/lib/shape/point/color.js +1 -1
- package/lib/shape/point/color.js.map +1 -1
- package/lib/shape/polygon/polygon.js +3 -3
- package/lib/shape/polygon/polygon.js.map +1 -1
- package/lib/shape/polygon/ribbon.js +3 -3
- package/lib/shape/polygon/ribbon.js.map +1 -1
- package/lib/shape/text/advance.js +1 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/badge.js +3 -3
- package/lib/shape/text/badge.js.map +1 -1
- package/lib/shape/text/text.js +1 -1
- package/lib/shape/text/text.js.map +1 -1
- package/lib/shape/utils.d.ts +4 -0
- package/lib/shape/utils.js +6 -1
- package/lib/shape/utils.js.map +1 -1
- package/lib/shape/vector/vector.js +3 -3
- package/lib/shape/vector/vector.js.map +1 -1
- package/lib/spec/composition.d.ts +2 -0
- package/lib/spec/data.d.ts +24 -9
- package/lib/spec/geometry.d.ts +2 -1
- package/lib/spec/interaction.d.ts +41 -6
- package/lib/spec/labelTransform.d.ts +24 -11
- package/lib/spec/theme.d.ts +5 -2
- package/lib/stdlib/index.js +3 -4
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.d.ts +3 -0
- package/lib/theme/academy.js +402 -0
- package/lib/theme/academy.js.map +1 -0
- package/lib/theme/dark.js +14 -20
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +3 -1
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/light.js +29 -22
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/maybeTooltip.js +3 -1
- package/lib/transform/maybeTooltip.js.map +1 -1
- package/lib/utils/bounds.d.ts +26 -0
- package/lib/utils/bounds.js +48 -0
- package/lib/utils/bounds.js.map +1 -0
- package/lib/utils/color.d.ts +6 -0
- package/lib/utils/color.js +11 -0
- package/lib/utils/color.js.map +1 -0
- package/lib/utils/coordinate.d.ts +1 -0
- package/lib/utils/coordinate.js +14 -1
- package/lib/utils/coordinate.js.map +1 -1
- package/lib/utils/helper.d.ts +1 -0
- package/lib/utils/helper.js +5 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +2 -2
- package/src/api/chart.ts +29 -8
- package/src/api/mark/mark.ts +1 -2
- package/src/api/mark/types.ts +1 -2
- package/src/component/axis.ts +38 -16
- package/src/component/index.ts +2 -0
- package/src/component/scrollbar.ts +41 -0
- package/src/component/scrollbarX.ts +16 -0
- package/src/component/scrollbarY.ts +16 -0
- package/src/component/slider.ts +1 -3
- package/src/component/title.ts +69 -30
- package/src/composition/mark.ts +2 -0
- package/src/data/fold.ts +6 -10
- package/src/data/index.ts +2 -2
- package/src/data/pick.ts +11 -2
- package/src/data/slice.ts +15 -0
- package/src/interaction/index.ts +23 -16
- package/src/interaction/native/brushAxisHighlight.ts +194 -0
- package/src/interaction/native/brushFilter.ts +163 -0
- package/src/interaction/native/brushHighlight.ts +419 -0
- package/src/interaction/native/brushXFilter.ts +9 -0
- package/src/interaction/native/brushXHighlight.ts +13 -0
- package/src/interaction/native/brushYFilter.ts +9 -0
- package/src/interaction/native/brushYHighlight.ts +13 -0
- package/src/interaction/native/legendFilter.ts +3 -14
- package/src/interaction/native/tooltip.ts +128 -38
- package/src/interaction/native/utils.ts +40 -0
- package/src/label-transform/contrastReverse.ts +56 -0
- package/src/label-transform/index.ts +8 -8
- package/src/label-transform/overflowHide.ts +23 -0
- package/src/label-transform/{dodgeY.ts → overlapDodgeY.ts} +6 -6
- package/src/label-transform/overlapHide.ts +32 -0
- package/src/mark/area.ts +1 -1
- package/src/mark/boxplot.ts +3 -1
- package/src/runtime/component.ts +46 -47
- package/src/runtime/layout.ts +6 -6
- package/src/runtime/plot.ts +40 -6
- package/src/runtime/render.ts +6 -58
- package/src/runtime/scale.ts +15 -7
- package/src/runtime/transform.ts +19 -6
- package/src/runtime/types/common.ts +27 -10
- package/src/runtime/types/options.ts +3 -5
- package/src/runtime/types/theme.ts +2 -5
- package/src/shape/area/curve.ts +15 -8
- package/src/shape/box/box.ts +6 -6
- package/src/shape/connector/connector.ts +2 -3
- package/src/shape/image/image.ts +2 -2
- package/src/shape/interval/color.ts +2 -1
- package/src/shape/label/label.ts +4 -3
- package/src/shape/label/position/area.ts +39 -0
- package/src/shape/label/position/bottom.ts +1 -0
- package/src/shape/label/position/bottomLeft.ts +1 -0
- package/src/shape/label/position/bottomRight.ts +1 -0
- package/src/shape/label/{position.ts → position/default.ts} +26 -110
- package/src/shape/label/position/index.ts +13 -0
- package/src/shape/label/position/inside.ts +1 -0
- package/src/shape/label/position/left.ts +1 -0
- package/src/shape/label/position/outside.ts +121 -0
- package/src/shape/label/position/right.ts +1 -0
- package/src/shape/label/position/spider.ts +39 -0
- package/src/shape/label/position/surround.ts +40 -0
- package/src/shape/label/position/top.ts +1 -0
- package/src/shape/label/position/topLeft.ts +1 -0
- package/src/shape/label/position/topRight.ts +1 -0
- package/src/shape/line/curve.ts +1 -1
- package/src/shape/lineXY/line.ts +2 -2
- package/src/shape/link/arc.ts +2 -2
- package/src/shape/link/link.ts +2 -2
- package/src/shape/link/smooth.ts +2 -2
- package/src/shape/link/vhv.ts +2 -2
- package/src/shape/point/color.ts +6 -5
- package/src/shape/polygon/polygon.ts +3 -3
- package/src/shape/polygon/ribbon.ts +3 -3
- package/src/shape/text/advance.ts +4 -1
- package/src/shape/text/badge.ts +8 -3
- package/src/shape/text/text.ts +1 -1
- package/src/shape/utils.ts +6 -5
- package/src/shape/vector/vector.ts +3 -3
- package/src/spec/action.ts +0 -1
- package/src/spec/composition.ts +2 -0
- package/src/spec/data.ts +25 -10
- package/src/spec/geometry.ts +3 -1
- package/src/spec/interaction.ts +59 -5
- package/src/spec/labelTransform.ts +29 -11
- package/src/spec/theme.ts +6 -2
- package/src/stdlib/index.ts +33 -9
- package/src/theme/academy.ts +404 -0
- package/src/theme/dark.ts +14 -20
- package/src/theme/index.ts +1 -0
- package/src/theme/light.ts +29 -22
- package/src/transform/maybeTooltip.ts +3 -1
- package/src/utils/bounds.ts +52 -0
- package/src/utils/color.ts +12 -0
- package/src/utils/coordinate.ts +12 -0
- package/src/utils/helper.ts +4 -0
- package/esm/data/subset.d.ts +0 -7
- package/esm/data/subset.js +0 -26
- package/esm/data/subset.js.map +0 -1
- package/esm/label-transform/dodgeY.d.ts +0 -7
- package/esm/label-transform/dodgeY.js.map +0 -1
- package/esm/label-transform/hideOverlap.d.ts +0 -4
- package/esm/label-transform/hideOverlap.js +0 -48
- package/esm/label-transform/hideOverlap.js.map +0 -1
- package/esm/label-transform/spider.d.ts +0 -7
- package/esm/label-transform/spider.js +0 -30
- package/esm/label-transform/spider.js.map +0 -1
- package/esm/label-transform/surround.d.ts +0 -7
- package/esm/label-transform/surround.js +0 -30
- package/esm/label-transform/surround.js.map +0 -1
- package/esm/shape/label/position.d.ts +0 -25
- package/esm/shape/label/position.js +0 -169
- package/esm/shape/label/position.js.map +0 -1
- package/lib/data/subset.d.ts +0 -7
- package/lib/data/subset.js +0 -30
- package/lib/data/subset.js.map +0 -1
- package/lib/label-transform/dodgeY.d.ts +0 -7
- package/lib/label-transform/dodgeY.js.map +0 -1
- package/lib/label-transform/hideOverlap.d.ts +0 -4
- package/lib/label-transform/hideOverlap.js +0 -52
- package/lib/label-transform/hideOverlap.js.map +0 -1
- package/lib/label-transform/spider.d.ts +0 -7
- package/lib/label-transform/spider.js +0 -34
- package/lib/label-transform/spider.js.map +0 -1
- package/lib/label-transform/surround.d.ts +0 -7
- package/lib/label-transform/surround.js +0 -34
- package/lib/label-transform/surround.js.map +0 -1
- package/lib/shape/label/position.d.ts +0 -25
- package/lib/shape/label/position.js.map +0 -1
- package/src/data/subset.ts +0 -35
- package/src/label-transform/hideOverlap.ts +0 -62
- package/src/label-transform/spider.ts +0 -37
- package/src/label-transform/surround.ts +0 -37
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { DisplayObject, IElement, Line } from '@antv/g';
|
|
2
|
-
import { sort,
|
|
2
|
+
import { sort, group, mean, range, bisector } from 'd3-array';
|
|
3
3
|
import { lowerFirst, throttle } from '@antv/util';
|
|
4
4
|
import { Tooltip as TooltipComponent } from '@antv/gui';
|
|
5
|
-
import {
|
|
5
|
+
import { Identity } from '@antv/scale';
|
|
6
|
+
import { defined, subObject, isStrictObject } from '../../utils/helper';
|
|
6
7
|
import {
|
|
7
8
|
selectG2Elements,
|
|
8
9
|
createXKey,
|
|
9
10
|
selectPlotArea,
|
|
10
11
|
mousePosition,
|
|
12
|
+
selectFacetG2Elements,
|
|
11
13
|
} from './utils';
|
|
12
14
|
|
|
13
15
|
function getContainer(group: IElement) {
|
|
@@ -34,6 +36,7 @@ function createTooltip(root, x0, y0) {
|
|
|
34
36
|
width: x1 - x,
|
|
35
37
|
height: y1 - y,
|
|
36
38
|
},
|
|
39
|
+
title: ' ',
|
|
37
40
|
position: 'bottom-right',
|
|
38
41
|
offset: [10, 10],
|
|
39
42
|
style: {
|
|
@@ -46,18 +49,18 @@ function createTooltip(root, x0, y0) {
|
|
|
46
49
|
},
|
|
47
50
|
},
|
|
48
51
|
});
|
|
52
|
+
// @ts-ignore
|
|
49
53
|
const container = getContainer(root);
|
|
50
54
|
container.appendChild(tooltipElement.HTMLTooltipElement);
|
|
51
55
|
return tooltipElement;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
function showTooltip(root, data, x, y) {
|
|
55
|
-
const tooltipElement =
|
|
59
|
+
const { tooltipElement = createTooltip(root, x, y) } = root;
|
|
56
60
|
const { items, title } = data;
|
|
57
61
|
tooltipElement.show();
|
|
62
|
+
tooltipElement.position = [x, y];
|
|
58
63
|
tooltipElement.update({
|
|
59
|
-
x,
|
|
60
|
-
y,
|
|
61
64
|
items,
|
|
62
65
|
title,
|
|
63
66
|
});
|
|
@@ -69,10 +72,6 @@ function hideTooltip(root) {
|
|
|
69
72
|
if (tooltipElement) tooltipElement.hide();
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
function unique(data) {
|
|
73
|
-
return Array.from(new Set(data));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
75
|
function filterDefined(obj) {
|
|
77
76
|
return Object.fromEntries(
|
|
78
77
|
Object.entries(obj).filter(([, value]) => defined(value)),
|
|
@@ -82,16 +81,24 @@ function filterDefined(obj) {
|
|
|
82
81
|
function singleItem(element, item, scale) {
|
|
83
82
|
const { __data__: datum } = element;
|
|
84
83
|
const { title, ...rest } = datum;
|
|
85
|
-
const
|
|
84
|
+
const defaultColor = itemColorOf(element);
|
|
86
85
|
const items = Object.entries(rest)
|
|
87
86
|
.filter(([key]) => key.startsWith('tooltip'))
|
|
88
87
|
.map(([key, d]: any) => {
|
|
89
|
-
const { field, title =
|
|
88
|
+
const { field: f, title = f } = scale[key].getOptions();
|
|
89
|
+
const {
|
|
90
|
+
field = undefined,
|
|
91
|
+
color = defaultColor,
|
|
92
|
+
name = field || title,
|
|
93
|
+
value,
|
|
94
|
+
...rest
|
|
95
|
+
} = normalizeTooltip(d);
|
|
90
96
|
return {
|
|
97
|
+
...rest,
|
|
91
98
|
color,
|
|
92
|
-
name
|
|
93
|
-
value
|
|
94
|
-
...filterDefined(item({ channel: key, value
|
|
99
|
+
name,
|
|
100
|
+
value,
|
|
101
|
+
...filterDefined(item({ channel: key, value })),
|
|
95
102
|
};
|
|
96
103
|
})
|
|
97
104
|
.filter(({ value }) => value !== undefined);
|
|
@@ -101,15 +108,18 @@ function singleItem(element, item, scale) {
|
|
|
101
108
|
};
|
|
102
109
|
}
|
|
103
110
|
|
|
104
|
-
function
|
|
111
|
+
function groupNameOf(scale, datum) {
|
|
105
112
|
const { color: scaleColor, series: scaleSeries } = scale;
|
|
106
113
|
const { color, series } = datum;
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
const invertAble = (scale) => {
|
|
115
|
+
return scale && scale.invert && !(scale instanceof Identity);
|
|
116
|
+
};
|
|
117
|
+
if (invertAble(scaleColor)) return scaleColor.invert(color);
|
|
118
|
+
if (invertAble(scaleSeries)) return scaleSeries.invert(series);
|
|
109
119
|
return null;
|
|
110
120
|
}
|
|
111
121
|
|
|
112
|
-
function
|
|
122
|
+
function itemColorOf(element) {
|
|
113
123
|
const fill = element.getAttribute('fill');
|
|
114
124
|
const stroke = element.getAttribute('stroke');
|
|
115
125
|
const { __data__: datum } = element;
|
|
@@ -117,26 +127,45 @@ function itemColorof(element) {
|
|
|
117
127
|
return color;
|
|
118
128
|
}
|
|
119
129
|
|
|
130
|
+
function normalizeTooltip(d) {
|
|
131
|
+
return isStrictObject(d) ? d : { value: d === undefined ? d : `${d}` };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function uniqueTitles(titles) {
|
|
135
|
+
const valueTitle = new Map(
|
|
136
|
+
titles.map((d) => [d instanceof Date ? +d : d, d]),
|
|
137
|
+
);
|
|
138
|
+
return Array.from(valueTitle.values());
|
|
139
|
+
}
|
|
140
|
+
|
|
120
141
|
function groupItems(
|
|
121
142
|
elements,
|
|
122
143
|
item,
|
|
123
144
|
scale,
|
|
124
145
|
data = elements.map((d) => d['__data__']),
|
|
125
146
|
) {
|
|
126
|
-
const T =
|
|
147
|
+
const T = uniqueTitles(data.map((d) => d.title)).filter(defined);
|
|
127
148
|
const items = data.flatMap((datum, i) => {
|
|
128
149
|
const element = elements[i];
|
|
129
150
|
const { title, ...rest } = datum;
|
|
130
|
-
const
|
|
151
|
+
const defaultColor = itemColorOf(element);
|
|
131
152
|
return Object.entries(rest)
|
|
132
153
|
.filter(([key]) => key.startsWith('tooltip'))
|
|
133
154
|
.map(([key, d]: any) => {
|
|
134
|
-
const { field, title =
|
|
155
|
+
const { field: f, title = f } = scale[key].getOptions();
|
|
156
|
+
const {
|
|
157
|
+
field = undefined,
|
|
158
|
+
color = defaultColor,
|
|
159
|
+
name = groupNameOf(scale, datum) || field || title,
|
|
160
|
+
value,
|
|
161
|
+
...rest
|
|
162
|
+
} = normalizeTooltip(d);
|
|
135
163
|
return {
|
|
164
|
+
...rest,
|
|
165
|
+
name,
|
|
136
166
|
color,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
...filterDefined(item({ channel: key, value: d })),
|
|
167
|
+
value,
|
|
168
|
+
...filterDefined(item({ channel: key, value })),
|
|
140
169
|
};
|
|
141
170
|
})
|
|
142
171
|
.filter(({ value }) => value !== undefined);
|
|
@@ -226,18 +255,63 @@ export function seriesTooltip(
|
|
|
226
255
|
) {
|
|
227
256
|
const elements = elementsof(root);
|
|
228
257
|
const [, height] = sizeof(root);
|
|
258
|
+
|
|
259
|
+
// Split elements into series elements and item elements.
|
|
260
|
+
const seriesElements = [];
|
|
261
|
+
const itemElements = [];
|
|
262
|
+
for (const element of elements) {
|
|
263
|
+
const { __data__: data } = element;
|
|
264
|
+
const { seriesX } = data;
|
|
265
|
+
if (seriesX) seriesElements.push(element);
|
|
266
|
+
else itemElements.push(element);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Get sortedIndex and X for each series elements
|
|
229
270
|
const elementSortedX = new Map(
|
|
230
|
-
|
|
271
|
+
seriesElements.map((element) => {
|
|
231
272
|
const { __data__: data } = element;
|
|
232
273
|
const { seriesX } = data;
|
|
233
|
-
|
|
274
|
+
const seriesIndex = seriesX.map((_, i) => i);
|
|
275
|
+
const sortedIndex = sort(seriesIndex, (i) => seriesX[+i]);
|
|
276
|
+
return [element, [sortedIndex, seriesX]];
|
|
234
277
|
}),
|
|
235
278
|
);
|
|
279
|
+
|
|
280
|
+
// Get sortedIndex and X for all item items.
|
|
281
|
+
const itemIndex = itemElements.map((_, i) => i);
|
|
282
|
+
const itemX = itemElements.map((element) => {
|
|
283
|
+
const { __data__: data } = element;
|
|
284
|
+
return data.x;
|
|
285
|
+
});
|
|
286
|
+
const itemSortedIndex = sort(itemIndex, (i) => itemX[i]);
|
|
287
|
+
|
|
236
288
|
const ruleStyle = subObject(rest, 'crosshairs');
|
|
289
|
+
const { x: scaleX } = scale;
|
|
237
290
|
|
|
238
|
-
|
|
291
|
+
// Apply offset for band scale x.
|
|
292
|
+
const offsetX = scaleX?.getBandWidth ? scaleX.getBandWidth() / 2 : 0;
|
|
293
|
+
|
|
294
|
+
const indexByFocus = (focus, I, X) => {
|
|
239
295
|
const [normalizedX] = coordinate.invert(focus);
|
|
240
|
-
|
|
296
|
+
const search = bisector((i) => X[+i]).center;
|
|
297
|
+
const i = search(I, normalizedX - offsetX);
|
|
298
|
+
return I[i];
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
const indicesByFocus = (focus, I, X) => {
|
|
302
|
+
const len = I.length;
|
|
303
|
+
if (len === 0) return [];
|
|
304
|
+
const [normalizedX] = coordinate.invert(focus);
|
|
305
|
+
const x = normalizedX - offsetX;
|
|
306
|
+
const search = bisector((i) => X[+i]).center;
|
|
307
|
+
const center = search(I, x);
|
|
308
|
+
|
|
309
|
+
// Find the least index and greatest index of X[center]
|
|
310
|
+
let left = center;
|
|
311
|
+
let right = center;
|
|
312
|
+
while (left - 1 > 0 && X[I[left - 1]] == X[I[center]]) left--;
|
|
313
|
+
while (right + 1 < len && X[I[right + 1]] === X[I[center]]) right++;
|
|
314
|
+
return range(left, right + 1).map((i) => I[i]);
|
|
241
315
|
};
|
|
242
316
|
|
|
243
317
|
const seriesData = (element, index) => {
|
|
@@ -255,23 +329,41 @@ export function seriesTooltip(
|
|
|
255
329
|
const update = throttle(
|
|
256
330
|
(event) => {
|
|
257
331
|
const mouse = mousePosition(root, event);
|
|
332
|
+
if (!mouse) return;
|
|
258
333
|
const bbox = root.getBounds();
|
|
259
334
|
const x = bbox.min[0];
|
|
260
335
|
const y = bbox.min[1];
|
|
261
336
|
const focus = [mouse[0] - startX, mouse[1] - startY];
|
|
262
337
|
if (!focus) return;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
338
|
+
// Get selected item element.
|
|
339
|
+
const selectedItemIndices = indicesByFocus(focus, itemSortedIndex, itemX);
|
|
340
|
+
const selectedItems = selectedItemIndices.map((i) => itemElements[i]);
|
|
341
|
+
|
|
342
|
+
// Get selected data item from both series element and item element.
|
|
343
|
+
const selectedSeriesData = seriesElements.map((element) => {
|
|
344
|
+
const [sortedIndex, X] = elementSortedX.get(element);
|
|
345
|
+
const index = indexByFocus(focus, sortedIndex, X);
|
|
266
346
|
const d = seriesData(element, index);
|
|
267
347
|
const { x, y } = d;
|
|
268
|
-
return [d, coordinate.map([x, y])] as const;
|
|
348
|
+
return [d, coordinate.map([x + offsetX, y])] as const;
|
|
269
349
|
});
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
350
|
+
const selectedData = [
|
|
351
|
+
...selectedSeriesData.map((d) => d[0]),
|
|
352
|
+
...selectedItems.map((d) => d.__data__),
|
|
353
|
+
];
|
|
354
|
+
|
|
355
|
+
// Get the displayed tooltip data.
|
|
356
|
+
const selectedElements = [...seriesElements, ...selectedItems];
|
|
357
|
+
const tooltipData = groupItems(
|
|
358
|
+
selectedElements,
|
|
359
|
+
item,
|
|
360
|
+
scale,
|
|
361
|
+
selectedData,
|
|
362
|
+
);
|
|
363
|
+
|
|
273
364
|
showTooltip(root, tooltipData, mouse[0] + x, mouse[1] + y);
|
|
274
365
|
if (crosshairs) {
|
|
366
|
+
const points = selectedSeriesData.map((d) => d[1]);
|
|
275
367
|
updateRuleY(root, points, { ...ruleStyle, height, startX, startY });
|
|
276
368
|
}
|
|
277
369
|
},
|
|
@@ -386,9 +478,7 @@ export function Tooltip(options) {
|
|
|
386
478
|
const facetInstances = viewInstances.filter(
|
|
387
479
|
(d) => d !== target && d.options.parentKey === target.options.key,
|
|
388
480
|
);
|
|
389
|
-
const elements =
|
|
390
|
-
selectG2Elements(container),
|
|
391
|
-
);
|
|
481
|
+
const elements = selectFacetG2Elements(target, viewInstances);
|
|
392
482
|
// Use the scale of the first view.
|
|
393
483
|
const scale = facetInstances[0].view.scale;
|
|
394
484
|
const bbox = plotArea.getBounds();
|
|
@@ -16,6 +16,13 @@ export function selectG2Elements(root: DisplayObject): DisplayObject[] {
|
|
|
16
16
|
return select(root).selectAll(`.${ELEMENT_CLASS_NAME}`).nodes();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
export function selectFacetG2Elements(target, viewInstances): DisplayObject[] {
|
|
20
|
+
const facetInstances = viewInstances.filter(
|
|
21
|
+
(d) => d !== target && d.options.parentKey === target.options.key,
|
|
22
|
+
);
|
|
23
|
+
return facetInstances.flatMap(({ container }) => selectG2Elements(container));
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
export function selectPlotArea(root: DisplayObject): DisplayObject {
|
|
20
27
|
return select(root).select(`.${PLOT_CLASS_NAME}`).node();
|
|
21
28
|
}
|
|
@@ -33,6 +40,28 @@ export function mousePosition(target, event) {
|
|
|
33
40
|
return [offsetX - x, offsetY - y];
|
|
34
41
|
}
|
|
35
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @todo Pass bbox rather than calc it here.
|
|
45
|
+
*/
|
|
46
|
+
export function brushMousePosition(target, event) {
|
|
47
|
+
const { offsetX, offsetY } = event;
|
|
48
|
+
const [x, y, x1, y1] = boundsOfBrushArea(target);
|
|
49
|
+
return [
|
|
50
|
+
Math.min(x1, Math.max(x, offsetX)) - x,
|
|
51
|
+
Math.min(y1, Math.max(y, offsetY)) - y,
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function boundsOfBrushArea(target) {
|
|
56
|
+
// Calc bbox after clipping.
|
|
57
|
+
const bbox = target.getRenderBounds();
|
|
58
|
+
const {
|
|
59
|
+
min: [x0, y0],
|
|
60
|
+
max: [x1, y1],
|
|
61
|
+
} = bbox;
|
|
62
|
+
return [x0, y0, x1, y1];
|
|
63
|
+
}
|
|
64
|
+
|
|
36
65
|
export function applyDefaultsHighlightedStyle(
|
|
37
66
|
style: Record<string, any>,
|
|
38
67
|
): Record<string, any> {
|
|
@@ -200,3 +229,14 @@ export function renderLink(
|
|
|
200
229
|
|
|
201
230
|
return [append, remove] as const;
|
|
202
231
|
}
|
|
232
|
+
|
|
233
|
+
export function setCursor(root, cursor) {
|
|
234
|
+
// @ts-ignore
|
|
235
|
+
const canvas = root.getRootNode().defaultView;
|
|
236
|
+
const dom = canvas.getContextService().getDomElement();
|
|
237
|
+
if (dom?.style) dom.style.cursor = cursor;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function restoreCursor(root) {
|
|
241
|
+
setCursor(root, 'default');
|
|
242
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DisplayObject } from '@antv/g';
|
|
2
|
+
import { maxIndex } from 'd3-array';
|
|
3
|
+
import { ContrastReverseTransform } from '../spec';
|
|
4
|
+
import { LabelTransformComponent as LLC } from '../runtime';
|
|
5
|
+
import { parseToRGB } from '../utils/color';
|
|
6
|
+
|
|
7
|
+
export type ContrastReverseOptions = Omit<ContrastReverseTransform, 'type'>;
|
|
8
|
+
|
|
9
|
+
function getsRGB(s: number) {
|
|
10
|
+
let c = s / 255;
|
|
11
|
+
c = c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
12
|
+
return c;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getL(r: number, g: number, b: number) {
|
|
16
|
+
return 0.2126 * getsRGB(r) + 0.7152 * getsRGB(g) + 0.0722 * getsRGB(b);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Calculate the contrast. see https://webaim.org/resources/contrastchecker/
|
|
21
|
+
* @param foreground
|
|
22
|
+
* @param background
|
|
23
|
+
*/
|
|
24
|
+
function contrast(foreground, background): number {
|
|
25
|
+
const { r, g, b } = foreground;
|
|
26
|
+
const { r: rb, g: gb, b: bb } = background;
|
|
27
|
+
const L1 = getL(r, g, b);
|
|
28
|
+
const L2 = getL(rb, gb, bb);
|
|
29
|
+
return (Math.max(L1, L2) + 0.05) / (Math.min(L1, L2) + 0.05);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reverse color for max contrast.
|
|
34
|
+
*/
|
|
35
|
+
function mostContrast(color, palette: string[]): string {
|
|
36
|
+
const i = maxIndex(palette, (c) => contrast(color, parseToRGB(c)));
|
|
37
|
+
return palette[i];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Reverse the label color when the contrast is lower then `threshold`.
|
|
42
|
+
* The default value of `threshold` is 4.5.
|
|
43
|
+
* More about contract, see https://webaim.org/resources/contrastchecker/
|
|
44
|
+
*/
|
|
45
|
+
export const ContrastReverse: LLC<ContrastReverseOptions> = (options) => {
|
|
46
|
+
const { threshold = 4.5, palette = ['#000', '#fff'] } = options;
|
|
47
|
+
return (labels: DisplayObject[], coordinate) => {
|
|
48
|
+
labels.forEach((l) => {
|
|
49
|
+
const background = l.attr('dependentElement').parsedStyle.fill;
|
|
50
|
+
const foreground = l.parsedStyle.fill;
|
|
51
|
+
const c = contrast(foreground, background);
|
|
52
|
+
if (c < threshold) l.attr('fill', mostContrast(background, palette));
|
|
53
|
+
});
|
|
54
|
+
return labels;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
export { OverlapHide } from './overlapHide';
|
|
2
|
+
export { OverlapDodgeY } from './overlapDodgeY';
|
|
3
|
+
export { ContrastReverse } from './contrastReverse';
|
|
4
|
+
export { OverflowHide } from './overflowHide';
|
|
5
5
|
|
|
6
|
-
export type {
|
|
7
|
-
export type {
|
|
8
|
-
export type {
|
|
9
|
-
export type {
|
|
6
|
+
export type { OverlapHideOptions } from './overlapHide';
|
|
7
|
+
export type { OverlapDodgeYOptions } from './overlapDodgeY';
|
|
8
|
+
export type { ContrastReverseOptions } from './contrastReverse';
|
|
9
|
+
export type { OverflowHideOptions } from './overflowHide';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DisplayObject } from '@antv/g';
|
|
2
|
+
import { OverflowHideTransform } from '../spec';
|
|
3
|
+
import { LabelTransformComponent as LLC } from '../runtime';
|
|
4
|
+
import { isOverflow, parseAABB } from '../utils/bounds';
|
|
5
|
+
|
|
6
|
+
export type OverflowHideOptions = Omit<OverflowHideTransform, 'type'>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hide the label when the label is overflowed from the element.
|
|
10
|
+
*/
|
|
11
|
+
export const OverflowHide: LLC<OverflowHideOptions> = (options) => {
|
|
12
|
+
return (labels: DisplayObject[], coordinate) => {
|
|
13
|
+
labels.forEach((l) => {
|
|
14
|
+
l.attr('visibility', 'visible');
|
|
15
|
+
|
|
16
|
+
const bounds = l.attr('bounds');
|
|
17
|
+
const b = l.getLocalBounds();
|
|
18
|
+
const overflow = isOverflow(parseAABB(b), bounds);
|
|
19
|
+
if (overflow) l.attr('visibility', 'hidden');
|
|
20
|
+
});
|
|
21
|
+
return labels;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
2
|
import { ascending } from 'd3-array';
|
|
3
|
-
import {
|
|
3
|
+
import { OverlapDodgeYTransform } from '../spec';
|
|
4
4
|
import { LabelTransformComponent as LLC } from '../runtime';
|
|
5
5
|
|
|
6
|
+
export type OverlapDodgeYOptions = Omit<OverlapDodgeYTransform, 'type'>;
|
|
7
|
+
|
|
6
8
|
function isSegmentIntersect([a, b], [c, d]) {
|
|
7
9
|
return d > a && b > c;
|
|
8
10
|
}
|
|
@@ -14,8 +16,6 @@ function useMap<K, V>() {
|
|
|
14
16
|
return [get, set] as const;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
export type DodgeYOptions = Omit<DodgeYLabelTransform, 'type'>;
|
|
18
|
-
|
|
19
19
|
function getBoundsWithoutConnector(shape: DisplayObject) {
|
|
20
20
|
const node = shape.cloneNode(true);
|
|
21
21
|
const connectorShape = node.getElementById('connector');
|
|
@@ -29,8 +29,8 @@ function getBoundsWithoutConnector(shape: DisplayObject) {
|
|
|
29
29
|
/**
|
|
30
30
|
* An iterative dodge method avoids label overlap. (n * log(n))
|
|
31
31
|
*/
|
|
32
|
-
export const
|
|
33
|
-
const {
|
|
32
|
+
export const OverlapDodgeY: LLC<OverlapDodgeYOptions> = (options) => {
|
|
33
|
+
const { maxIterations = 10, maxError = 0.1, padding = 1 } = options;
|
|
34
34
|
return (labels: DisplayObject[]) => {
|
|
35
35
|
const n = labels.length;
|
|
36
36
|
if (n <= 1) return labels;
|
|
@@ -51,7 +51,7 @@ export const DodgeY: LLC<DodgeYOptions> = (options) => {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Offsets position Y.
|
|
54
|
-
for (let iter = 0; iter <
|
|
54
|
+
for (let iter = 0; iter < maxIterations; iter++) {
|
|
55
55
|
labels.sort((a, b) => ascending(y(a), y(b)));
|
|
56
56
|
let error = 0;
|
|
57
57
|
for (let i = 0; i < n - 1; i++) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DisplayObject } from '@antv/g';
|
|
2
|
+
import { LabelTransformComponent as LLC } from '../runtime';
|
|
3
|
+
import { OverlapHideTransform } from '../spec';
|
|
4
|
+
import { isOverlap, parseAABB } from '../utils/bounds';
|
|
5
|
+
|
|
6
|
+
export type OverlapHideOptions = Omit<OverlapHideTransform, 'type'>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hide the label when overlap.
|
|
10
|
+
*/
|
|
11
|
+
export const OverlapHide: LLC<OverlapHideOptions> = (options) => {
|
|
12
|
+
const { priority } = options;
|
|
13
|
+
return (labels: DisplayObject[], coordinate) => {
|
|
14
|
+
const displayLabels = [];
|
|
15
|
+
// When overlap, will hide the next label.
|
|
16
|
+
if (priority) labels.sort(priority);
|
|
17
|
+
|
|
18
|
+
labels.forEach((l) => {
|
|
19
|
+
l.attr('visibility', 'visible');
|
|
20
|
+
|
|
21
|
+
const b1 = l.getLocalBounds();
|
|
22
|
+
const overlaping = displayLabels.some((dl) =>
|
|
23
|
+
isOverlap(parseAABB(b1), parseAABB(dl.getLocalBounds())),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (overlaping) l.attr('visibility', 'hidden');
|
|
27
|
+
else displayLabels.push(l);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return labels;
|
|
31
|
+
};
|
|
32
|
+
};
|
package/src/mark/area.ts
CHANGED
package/src/mark/boxplot.ts
CHANGED
|
@@ -56,7 +56,7 @@ function OutlierY() {
|
|
|
56
56
|
|
|
57
57
|
export const Boxplot: CC<BoxPlotOptions> = (options) => {
|
|
58
58
|
return () => {
|
|
59
|
-
const { data, encode, style = {} } = options;
|
|
59
|
+
const { data, encode, style = {}, ...rest } = options;
|
|
60
60
|
const { extend = false, ...restStyle } = style;
|
|
61
61
|
const { y } = encode;
|
|
62
62
|
const encodeY = { y, y1: y, y2: y, y3: y, y4: y };
|
|
@@ -79,6 +79,7 @@ export const Boxplot: CC<BoxPlotOptions> = (options) => {
|
|
|
79
79
|
],
|
|
80
80
|
encode: { ...encode, ...encodeY },
|
|
81
81
|
style: restStyle,
|
|
82
|
+
...rest,
|
|
82
83
|
},
|
|
83
84
|
];
|
|
84
85
|
}
|
|
@@ -99,6 +100,7 @@ export const Boxplot: CC<BoxPlotOptions> = (options) => {
|
|
|
99
100
|
],
|
|
100
101
|
encode: { ...encode, ...encodeY },
|
|
101
102
|
style: boxStyle,
|
|
103
|
+
...rest,
|
|
102
104
|
},
|
|
103
105
|
// Draw outliers.
|
|
104
106
|
{
|