@antv/g2 5.0.18 → 5.0.20
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 +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/api/chart.d.ts +175 -85
- package/esm/api/chart.js +3 -259
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition.d.ts +37 -0
- package/esm/api/{composition/base.js → composition.js} +17 -5
- package/esm/api/composition.js.map +1 -0
- package/esm/api/define.d.ts +14 -0
- package/esm/api/define.js +92 -0
- package/esm/api/define.js.map +1 -0
- package/esm/api/extend.d.ts +10 -0
- package/esm/api/extend.js +9 -0
- package/esm/api/extend.js.map +1 -0
- package/esm/api/index.d.ts +2 -0
- package/esm/api/index.js +2 -0
- package/esm/api/index.js.map +1 -1
- package/esm/api/library.d.ts +171 -1
- package/esm/api/library.js +2 -2
- package/esm/api/library.js.map +1 -1
- package/esm/api/mark.d.ts +29 -0
- package/esm/api/{mark/base.js → mark.js} +16 -4
- package/esm/api/mark.js.map +1 -0
- package/esm/api/node.d.ts +2 -2
- package/esm/api/node.js.map +1 -1
- package/esm/api/props.d.ts +170 -12
- package/esm/api/props.js +21 -102
- package/esm/api/props.js.map +1 -1
- package/esm/api/runtime.d.ts +66 -0
- package/esm/api/runtime.js +294 -0
- package/esm/api/runtime.js.map +1 -0
- package/esm/api/types.d.ts +60 -5
- package/esm/api/utils.d.ts +1 -1
- package/esm/api/utils.js +11 -13
- package/esm/api/utils.js.map +1 -1
- package/esm/component/axis.js +7 -4
- package/esm/component/axis.js.map +1 -1
- package/esm/component/legendCategory.js +4 -5
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/composition/d3Projection.js.map +1 -0
- package/esm/composition/geoPath.js.map +1 -0
- package/esm/{geo → composition}/geoView.js +1 -1
- package/esm/composition/geoView.js.map +1 -0
- package/esm/composition/index.d.ts +2 -0
- package/esm/composition/index.js +2 -0
- package/esm/composition/index.js.map +1 -1
- package/esm/data/index.d.ts +2 -0
- package/esm/data/index.js +1 -0
- package/esm/data/index.js.map +1 -1
- package/esm/data/log.d.ts +7 -0
- package/esm/data/log.js +11 -0
- package/esm/data/log.js.map +1 -0
- package/esm/index.d.ts +4 -3
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/interaction/brushFilter.js +18 -16
- package/esm/interaction/brushFilter.js.map +1 -1
- package/esm/interaction/chartIndex.js +25 -22
- package/esm/interaction/chartIndex.js.map +1 -1
- package/esm/interaction/fisheye.js +17 -13
- package/esm/interaction/fisheye.js.map +1 -1
- package/esm/interaction/legendFilter.js +32 -26
- package/esm/interaction/legendFilter.js.map +1 -1
- package/esm/interaction/sliderFilter.js +8 -9
- package/esm/interaction/sliderFilter.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +1 -1
- package/esm/interaction/tooltip.js +39 -4
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/label-transform/overlapDodgeY.js.map +1 -1
- package/esm/lib/core.d.ts +159 -0
- package/esm/lib/core.js +175 -0
- package/esm/lib/core.js.map +1 -0
- package/esm/lib/geo.d.ts +4 -0
- package/esm/lib/geo.js +9 -0
- package/esm/lib/geo.js.map +1 -0
- package/esm/lib/graph.d.ts +4 -0
- package/esm/lib/graph.js +8 -0
- package/esm/lib/graph.js.map +1 -0
- package/esm/lib/index.d.ts +6 -0
- package/esm/lib/index.js +7 -0
- package/esm/lib/index.js.map +1 -0
- package/esm/lib/lite.d.ts +64 -0
- package/esm/lib/lite.js +78 -0
- package/esm/lib/lite.js.map +1 -0
- package/esm/lib/plot.d.ts +11 -0
- package/esm/lib/plot.js +16 -0
- package/esm/lib/plot.js.map +1 -0
- package/esm/lib/std.d.ts +171 -0
- package/esm/lib/std.js +8 -0
- package/esm/lib/std.js.map +1 -0
- package/esm/mark/area.js +14 -5
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/box.js +9 -2
- package/esm/mark/box.js.map +1 -1
- package/esm/mark/cell.js +11 -5
- package/esm/mark/cell.js.map +1 -1
- package/esm/mark/connector.js +6 -2
- package/esm/mark/connector.js.map +1 -1
- package/esm/mark/density.js +10 -7
- package/esm/mark/density.js.map +1 -1
- package/esm/mark/forceGraph.js +0 -3
- package/esm/mark/forceGraph.js.map +1 -1
- package/esm/mark/heatmap.js +9 -4
- package/esm/mark/heatmap.js.map +1 -1
- package/esm/mark/image.js +9 -4
- package/esm/mark/image.js.map +1 -1
- package/esm/mark/interval.js +13 -7
- package/esm/mark/interval.js.map +1 -1
- package/esm/mark/line.js +15 -4
- package/esm/mark/line.js.map +1 -1
- package/esm/mark/lineX.js +8 -3
- package/esm/mark/lineX.js.map +1 -1
- package/esm/mark/lineY.js +8 -3
- package/esm/mark/lineY.js.map +1 -1
- package/esm/mark/link.js +12 -4
- package/esm/mark/link.js.map +1 -1
- package/esm/mark/path.js +7 -2
- package/esm/mark/path.js.map +1 -1
- package/esm/mark/point.js +28 -29
- package/esm/mark/point.js.map +1 -1
- package/esm/mark/polygon.js +7 -2
- package/esm/mark/polygon.js.map +1 -1
- package/esm/mark/range.js +4 -2
- package/esm/mark/range.js.map +1 -1
- package/esm/mark/rangeX.js +6 -2
- package/esm/mark/rangeX.js.map +1 -1
- package/esm/mark/rangeY.js +6 -2
- package/esm/mark/rangeY.js.map +1 -1
- package/esm/mark/rect.js +9 -3
- package/esm/mark/rect.js.map +1 -1
- package/esm/mark/shape.js +9 -3
- package/esm/mark/shape.js.map +1 -1
- package/esm/mark/text.js +10 -4
- package/esm/mark/text.js.map +1 -1
- package/esm/mark/treemap.js.map +1 -1
- package/esm/mark/utils.d.ts +11 -8
- package/esm/mark/utils.js +8 -7
- package/esm/mark/utils.js.map +1 -1
- package/esm/mark/vector.js +6 -2
- package/esm/mark/vector.js.map +1 -1
- package/esm/runtime/index.d.ts +1 -1
- package/esm/runtime/index.js +1 -1
- package/esm/runtime/index.js.map +1 -1
- package/esm/runtime/plot.js +32 -13
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js +3 -6
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/types/component.d.ts +1 -1
- package/esm/runtime/types/mark.d.ts +4 -0
- package/esm/runtime/types/options.d.ts +4 -1
- package/esm/shape/index.d.ts +106 -101
- package/esm/shape/index.js +58 -53
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/text/advance.js +3 -3
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/spec/composition.d.ts +7 -0
- package/esm/spec/dataTransform.d.ts +3 -2
- package/esm/spec/index.d.ts +1 -0
- package/esm/spec/index.js.map +1 -1
- package/esm/spec/interaction.d.ts +4 -1
- package/esm/theme/academy.js +6 -6
- package/esm/theme/classic.js +6 -7
- package/esm/theme/classic.js.map +1 -1
- package/esm/theme/classicDark.js +6 -6
- package/esm/utils/coordinate.d.ts +2 -2
- package/esm/utils/scale.d.ts +1 -1
- package/esm/utils/scale.js +1 -1
- package/esm/utils/scale.js.map +1 -1
- package/lib/api/chart.d.ts +175 -85
- package/lib/api/chart.js +4 -263
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition.d.ts +37 -0
- package/lib/api/{composition/base.js → composition.js} +16 -5
- package/lib/api/composition.js.map +1 -0
- package/lib/api/define.d.ts +14 -0
- package/lib/api/define.js +97 -0
- package/lib/api/define.js.map +1 -0
- package/lib/api/extend.d.ts +10 -0
- package/lib/api/extend.js +13 -0
- package/lib/api/extend.js.map +1 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +5 -1
- package/lib/api/index.js.map +1 -1
- package/lib/api/library.d.ts +171 -1
- package/lib/api/library.js +2 -2
- package/lib/api/library.js.map +1 -1
- package/lib/api/mark.d.ts +29 -0
- package/lib/api/{mark/base.js → mark.js} +15 -4
- package/lib/api/mark.js.map +1 -0
- package/lib/api/node.d.ts +2 -2
- package/lib/api/node.js.map +1 -1
- package/lib/api/props.d.ts +170 -12
- package/lib/api/props.js +22 -106
- package/lib/api/props.js.map +1 -1
- package/lib/api/runtime.d.ts +66 -0
- package/lib/api/runtime.js +301 -0
- package/lib/api/runtime.js.map +1 -0
- package/lib/api/types.d.ts +60 -5
- package/lib/api/utils.d.ts +1 -1
- package/lib/api/utils.js +14 -16
- package/lib/api/utils.js.map +1 -1
- package/lib/component/axis.js +7 -4
- package/lib/component/axis.js.map +1 -1
- package/lib/component/legendCategory.js +4 -5
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/composition/d3Projection.js.map +1 -0
- package/lib/composition/geoPath.js.map +1 -0
- package/lib/{geo → composition}/geoView.js +1 -1
- package/lib/composition/geoView.js.map +1 -0
- package/lib/composition/index.d.ts +2 -0
- package/lib/composition/index.js +5 -1
- package/lib/composition/index.js.map +1 -1
- package/lib/data/index.d.ts +2 -0
- package/lib/data/index.js +3 -1
- package/lib/data/index.js.map +1 -1
- package/lib/data/log.d.ts +7 -0
- package/lib/data/log.js +15 -0
- package/lib/data/log.js.map +1 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +8 -3
- package/lib/index.js.map +1 -1
- package/lib/interaction/brushFilter.js +18 -16
- package/lib/interaction/brushFilter.js.map +1 -1
- package/lib/interaction/chartIndex.js +25 -22
- package/lib/interaction/chartIndex.js.map +1 -1
- package/lib/interaction/fisheye.js +17 -13
- package/lib/interaction/fisheye.js.map +1 -1
- package/lib/interaction/legendFilter.js +32 -26
- package/lib/interaction/legendFilter.js.map +1 -1
- package/lib/interaction/sliderFilter.js +8 -9
- package/lib/interaction/sliderFilter.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +1 -1
- package/lib/interaction/tooltip.js +38 -3
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/label-transform/overlapDodgeY.js.map +1 -1
- package/lib/lib/core.d.ts +159 -0
- package/lib/lib/core.js +179 -0
- package/lib/lib/core.js.map +1 -0
- package/lib/lib/geo.d.ts +4 -0
- package/lib/lib/geo.js +13 -0
- package/lib/lib/geo.js.map +1 -0
- package/lib/lib/graph.d.ts +4 -0
- package/lib/lib/graph.js +12 -0
- package/lib/lib/graph.js.map +1 -0
- package/lib/lib/index.d.ts +6 -0
- package/lib/lib/index.js +16 -0
- package/lib/lib/index.js.map +1 -0
- package/lib/lib/lite.d.ts +64 -0
- package/lib/lib/lite.js +82 -0
- package/lib/lib/lite.js.map +1 -0
- package/lib/lib/plot.d.ts +11 -0
- package/lib/lib/plot.js +20 -0
- package/lib/lib/plot.js.map +1 -0
- package/lib/lib/std.d.ts +171 -0
- package/lib/lib/std.js +12 -0
- package/lib/lib/std.js.map +1 -0
- package/lib/mark/area.js +14 -5
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/box.js +9 -2
- package/lib/mark/box.js.map +1 -1
- package/lib/mark/cell.js +11 -5
- package/lib/mark/cell.js.map +1 -1
- package/lib/mark/connector.js +6 -2
- package/lib/mark/connector.js.map +1 -1
- package/lib/mark/density.js +10 -7
- package/lib/mark/density.js.map +1 -1
- package/lib/mark/forceGraph.js +0 -3
- package/lib/mark/forceGraph.js.map +1 -1
- package/lib/mark/heatmap.js +9 -4
- package/lib/mark/heatmap.js.map +1 -1
- package/lib/mark/image.js +9 -4
- package/lib/mark/image.js.map +1 -1
- package/lib/mark/interval.js +13 -7
- package/lib/mark/interval.js.map +1 -1
- package/lib/mark/line.js +15 -4
- package/lib/mark/line.js.map +1 -1
- package/lib/mark/lineX.js +8 -3
- package/lib/mark/lineX.js.map +1 -1
- package/lib/mark/lineY.js +8 -3
- package/lib/mark/lineY.js.map +1 -1
- package/lib/mark/link.js +12 -4
- package/lib/mark/link.js.map +1 -1
- package/lib/mark/path.js +7 -2
- package/lib/mark/path.js.map +1 -1
- package/lib/mark/point.js +28 -29
- package/lib/mark/point.js.map +1 -1
- package/lib/mark/polygon.js +7 -2
- package/lib/mark/polygon.js.map +1 -1
- package/lib/mark/range.js +4 -2
- package/lib/mark/range.js.map +1 -1
- package/lib/mark/rangeX.js +6 -2
- package/lib/mark/rangeX.js.map +1 -1
- package/lib/mark/rangeY.js +6 -2
- package/lib/mark/rangeY.js.map +1 -1
- package/lib/mark/rect.js +9 -3
- package/lib/mark/rect.js.map +1 -1
- package/lib/mark/shape.js +9 -3
- package/lib/mark/shape.js.map +1 -1
- package/lib/mark/text.js +10 -4
- package/lib/mark/text.js.map +1 -1
- package/lib/mark/treemap.js.map +1 -1
- package/lib/mark/utils.d.ts +11 -8
- package/lib/mark/utils.js +8 -7
- package/lib/mark/utils.js.map +1 -1
- package/lib/mark/vector.js +6 -2
- package/lib/mark/vector.js.map +1 -1
- package/lib/runtime/index.d.ts +1 -1
- package/lib/runtime/index.js +4 -4
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/plot.js +32 -13
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +3 -6
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/types/component.d.ts +1 -1
- package/lib/runtime/types/mark.d.ts +4 -0
- package/lib/runtime/types/options.d.ts +4 -1
- package/lib/shape/index.d.ts +106 -101
- package/lib/shape/index.js +71 -61
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/text/advance.js +3 -3
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/spec/composition.d.ts +7 -0
- package/lib/spec/dataTransform.d.ts +3 -2
- package/lib/spec/index.d.ts +1 -0
- package/lib/spec/index.js.map +1 -1
- package/lib/spec/interaction.d.ts +4 -1
- package/lib/theme/academy.js +6 -6
- package/lib/theme/classic.js +6 -7
- package/lib/theme/classic.js.map +1 -1
- package/lib/theme/classicDark.js +6 -6
- package/lib/utils/coordinate.d.ts +2 -2
- package/lib/utils/scale.d.ts +1 -1
- package/lib/utils/scale.js +1 -1
- package/lib/utils/scale.js.map +1 -1
- package/package.json +8 -7
- package/src/api/chart.ts +5 -341
- package/src/api/{composition/base.ts → composition.ts} +16 -8
- package/src/api/define.ts +128 -0
- package/src/api/extend.ts +36 -0
- package/src/api/index.ts +2 -0
- package/src/api/library.ts +2 -2
- package/src/api/{mark/base.ts → mark.ts} +10 -7
- package/src/api/node.ts +3 -3
- package/src/api/props.ts +30 -114
- package/src/api/runtime.ts +366 -0
- package/src/api/types.ts +95 -17
- package/src/api/utils.ts +28 -11
- package/src/component/axis.ts +10 -5
- package/src/component/legendCategory.ts +4 -6
- package/src/{geo → composition}/geoView.ts +1 -1
- package/src/composition/index.ts +2 -0
- package/src/data/index.ts +2 -0
- package/src/data/log.ts +16 -0
- package/src/index.ts +12 -3
- package/src/interaction/brushFilter.ts +31 -28
- package/src/interaction/chartIndex.ts +26 -23
- package/src/interaction/fisheye.ts +16 -12
- package/src/interaction/legendFilter.ts +45 -40
- package/src/interaction/sliderFilter.ts +15 -16
- package/src/interaction/tooltip.ts +47 -3
- package/src/label-transform/overlapDodgeY.ts +0 -1
- package/src/{stdlib/index.ts → lib/core.ts} +76 -258
- package/src/lib/geo.ts +9 -0
- package/src/lib/graph.ts +8 -0
- package/src/lib/index.ts +6 -0
- package/src/lib/lite.ts +127 -0
- package/src/lib/plot.ts +16 -0
- package/src/lib/std.ts +13 -0
- package/src/mark/area.ts +15 -6
- package/src/mark/box.ts +10 -2
- package/src/mark/cell.ts +12 -6
- package/src/mark/connector.ts +7 -3
- package/src/mark/density.ts +11 -8
- package/src/mark/forceGraph.ts +0 -3
- package/src/mark/heatmap.ts +10 -5
- package/src/mark/image.ts +10 -5
- package/src/mark/interval.ts +22 -10
- package/src/mark/line.ts +23 -5
- package/src/mark/lineX.ts +9 -4
- package/src/mark/lineY.ts +9 -4
- package/src/mark/link.ts +13 -5
- package/src/mark/path.ts +8 -3
- package/src/mark/point.ts +49 -30
- package/src/mark/polygon.ts +8 -3
- package/src/mark/range.ts +5 -3
- package/src/mark/rangeX.ts +7 -3
- package/src/mark/rangeY.ts +7 -3
- package/src/mark/rect.ts +10 -4
- package/src/mark/shape.ts +14 -3
- package/src/mark/text.ts +11 -5
- package/src/mark/treemap.ts +0 -1
- package/src/mark/utils.ts +9 -8
- package/src/mark/vector.ts +7 -3
- package/src/runtime/index.ts +1 -1
- package/src/runtime/plot.ts +41 -17
- package/src/runtime/render.ts +3 -6
- package/src/runtime/types/component.ts +1 -2
- package/src/runtime/types/mark.ts +4 -0
- package/src/runtime/types/options.ts +4 -1
- package/src/shape/index.ts +106 -110
- package/src/shape/text/advance.ts +1 -2
- package/src/spec/composition.ts +7 -0
- package/src/spec/dataTransform.ts +5 -0
- package/src/spec/index.ts +1 -0
- package/src/spec/interaction.ts +5 -1
- package/src/theme/academy.ts +6 -6
- package/src/theme/classic.ts +6 -7
- package/src/theme/classicDark.ts +6 -6
- package/src/utils/scale.ts +1 -1
- package/esm/api/composition/base.d.ts +0 -28
- package/esm/api/composition/base.js.map +0 -1
- package/esm/api/composition/facetCircle.d.ts +0 -17
- package/esm/api/composition/facetCircle.js +0 -27
- package/esm/api/composition/facetCircle.js.map +0 -1
- package/esm/api/composition/facetRect.d.ts +0 -17
- package/esm/api/composition/facetRect.js +0 -27
- package/esm/api/composition/facetRect.js.map +0 -1
- package/esm/api/composition/geoPath.d.ts +0 -20
- package/esm/api/composition/geoPath.js +0 -30
- package/esm/api/composition/geoPath.js.map +0 -1
- package/esm/api/composition/geoView.d.ts +0 -19
- package/esm/api/composition/geoView.js +0 -28
- package/esm/api/composition/geoView.js.map +0 -1
- package/esm/api/composition/index.d.ts +0 -33
- package/esm/api/composition/index.js +0 -32
- package/esm/api/composition/index.js.map +0 -1
- package/esm/api/composition/repeatMatrix.d.ts +0 -17
- package/esm/api/composition/repeatMatrix.js +0 -27
- package/esm/api/composition/repeatMatrix.js.map +0 -1
- package/esm/api/composition/spaceFlex.d.ts +0 -12
- package/esm/api/composition/spaceFlex.js +0 -19
- package/esm/api/composition/spaceFlex.js.map +0 -1
- package/esm/api/composition/spaceLayer.d.ts +0 -12
- package/esm/api/composition/spaceLayer.js +0 -19
- package/esm/api/composition/spaceLayer.js.map +0 -1
- package/esm/api/composition/timingKeyframe.d.ts +0 -11
- package/esm/api/composition/timingKeyframe.js +0 -19
- package/esm/api/composition/timingKeyframe.js.map +0 -1
- package/esm/api/composition/view.d.ts +0 -19
- package/esm/api/composition/view.js +0 -29
- package/esm/api/composition/view.js.map +0 -1
- package/esm/api/mark/base.d.ts +0 -22
- package/esm/api/mark/base.js.map +0 -1
- package/esm/api/mark/index.d.ts +0 -75
- package/esm/api/mark/index.js +0 -39
- package/esm/api/mark/index.js.map +0 -1
- package/esm/api/mark/mark.d.ts +0 -212
- package/esm/api/mark/mark.js +0 -339
- package/esm/api/mark/mark.js.map +0 -1
- package/esm/api/mark/types.d.ts +0 -26
- package/esm/api/mark/types.js +0 -2
- package/esm/api/mark/types.js.map +0 -1
- package/esm/geo/d3Projection.js.map +0 -1
- package/esm/geo/geoPath.js.map +0 -1
- package/esm/geo/geoView.js.map +0 -1
- package/esm/geo/index.d.ts +0 -9
- package/esm/geo/index.js +0 -8
- package/esm/geo/index.js.map +0 -1
- package/esm/stdlib/index.d.ts +0 -2
- package/esm/stdlib/index.js +0 -21
- package/esm/stdlib/index.js.map +0 -1
- package/lib/api/composition/base.d.ts +0 -28
- package/lib/api/composition/base.js.map +0 -1
- package/lib/api/composition/facetCircle.d.ts +0 -17
- package/lib/api/composition/facetCircle.js +0 -30
- package/lib/api/composition/facetCircle.js.map +0 -1
- package/lib/api/composition/facetRect.d.ts +0 -17
- package/lib/api/composition/facetRect.js +0 -30
- package/lib/api/composition/facetRect.js.map +0 -1
- package/lib/api/composition/geoPath.d.ts +0 -20
- package/lib/api/composition/geoPath.js +0 -33
- package/lib/api/composition/geoPath.js.map +0 -1
- package/lib/api/composition/geoView.d.ts +0 -19
- package/lib/api/composition/geoView.js +0 -31
- package/lib/api/composition/geoView.js.map +0 -1
- package/lib/api/composition/index.d.ts +0 -33
- package/lib/api/composition/index.js +0 -44
- package/lib/api/composition/index.js.map +0 -1
- package/lib/api/composition/repeatMatrix.d.ts +0 -17
- package/lib/api/composition/repeatMatrix.js +0 -30
- package/lib/api/composition/repeatMatrix.js.map +0 -1
- package/lib/api/composition/spaceFlex.d.ts +0 -12
- package/lib/api/composition/spaceFlex.js +0 -22
- package/lib/api/composition/spaceFlex.js.map +0 -1
- package/lib/api/composition/spaceLayer.d.ts +0 -12
- package/lib/api/composition/spaceLayer.js +0 -22
- package/lib/api/composition/spaceLayer.js.map +0 -1
- package/lib/api/composition/timingKeyframe.d.ts +0 -11
- package/lib/api/composition/timingKeyframe.js +0 -22
- package/lib/api/composition/timingKeyframe.js.map +0 -1
- package/lib/api/composition/view.d.ts +0 -19
- package/lib/api/composition/view.js +0 -32
- package/lib/api/composition/view.js.map +0 -1
- package/lib/api/mark/base.d.ts +0 -22
- package/lib/api/mark/base.js.map +0 -1
- package/lib/api/mark/index.d.ts +0 -75
- package/lib/api/mark/index.js +0 -43
- package/lib/api/mark/index.js.map +0 -1
- package/lib/api/mark/mark.d.ts +0 -212
- package/lib/api/mark/mark.js +0 -342
- package/lib/api/mark/mark.js.map +0 -1
- package/lib/api/mark/types.d.ts +0 -26
- package/lib/api/mark/types.js +0 -3
- package/lib/api/mark/types.js.map +0 -1
- package/lib/geo/d3Projection.js.map +0 -1
- package/lib/geo/geoPath.js.map +0 -1
- package/lib/geo/geoView.js.map +0 -1
- package/lib/geo/index.d.ts +0 -9
- package/lib/geo/index.js +0 -12
- package/lib/geo/index.js.map +0 -1
- package/lib/stdlib/index.d.ts +0 -2
- package/lib/stdlib/index.js +0 -25
- package/lib/stdlib/index.js.map +0 -1
- package/src/api/composition/facetCircle.ts +0 -36
- package/src/api/composition/facetRect.ts +0 -36
- package/src/api/composition/geoPath.ts +0 -37
- package/src/api/composition/geoView.ts +0 -39
- package/src/api/composition/index.ts +0 -57
- package/src/api/composition/repeatMatrix.ts +0 -36
- package/src/api/composition/spaceFlex.ts +0 -18
- package/src/api/composition/spaceLayer.ts +0 -18
- package/src/api/composition/timingKeyframe.ts +0 -16
- package/src/api/composition/view.ts +0 -42
- package/src/api/mark/index.ts +0 -113
- package/src/api/mark/mark.ts +0 -439
- package/src/api/mark/types.ts +0 -31
- package/src/geo/index.ts +0 -12
- /package/esm/{geo → composition}/d3Projection.d.ts +0 -0
- /package/esm/{geo → composition}/d3Projection.js +0 -0
- /package/esm/{geo → composition}/geoPath.d.ts +0 -0
- /package/esm/{geo → composition}/geoPath.js +0 -0
- /package/esm/{geo → composition}/geoView.d.ts +0 -0
- /package/lib/{geo → composition}/d3Projection.d.ts +0 -0
- /package/lib/{geo → composition}/d3Projection.js +0 -0
- /package/lib/{geo → composition}/geoPath.d.ts +0 -0
- /package/lib/{geo → composition}/geoPath.js +0 -0
- /package/lib/{geo → composition}/geoView.d.ts +0 -0
- /package/src/{geo → composition}/d3Projection.ts +0 -0
- /package/src/{geo → composition}/geoPath.ts +0 -0
package/src/api/utils.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { G2ViewTree } from '../runtime';
|
|
|
2
2
|
import { getContainerSize } from '../utils/size';
|
|
3
3
|
import { deepAssign } from '../utils/helper';
|
|
4
4
|
import { Node } from './node';
|
|
5
|
-
import { mark } from './mark';
|
|
6
|
-
import { composition } from './composition';
|
|
7
5
|
|
|
8
6
|
// Keys can specified by new Chart({...}).
|
|
9
7
|
// Keys can bubble form mark-level options to view-level options.
|
|
@@ -90,7 +88,10 @@ export function optionsOf(node: Node): Record<string, any> {
|
|
|
90
88
|
return nodeValue.get(root);
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
function isMark(
|
|
91
|
+
function isMark(
|
|
92
|
+
type: string | ((...args: any[]) => any),
|
|
93
|
+
mark: Record<string, new () => Node>,
|
|
94
|
+
): boolean {
|
|
94
95
|
if (typeof type === 'function') return true;
|
|
95
96
|
return new Set(Object.keys(mark)).has(type);
|
|
96
97
|
}
|
|
@@ -99,11 +100,12 @@ function normalizeRootOptions(
|
|
|
99
100
|
node: Node,
|
|
100
101
|
options: G2ViewTree,
|
|
101
102
|
previousType: string,
|
|
103
|
+
marks: Record<string, new () => Node>,
|
|
102
104
|
) {
|
|
103
105
|
const { type: oldType } = node;
|
|
104
106
|
const { type = previousType || oldType } = options;
|
|
105
107
|
if (type === 'view') return options;
|
|
106
|
-
if (!isMark(type)) return options;
|
|
108
|
+
if (!isMark(type, marks)) return options;
|
|
107
109
|
const view = { type: 'view' };
|
|
108
110
|
const mark = { ...options };
|
|
109
111
|
for (const key of VIEW_KEYS) {
|
|
@@ -115,7 +117,11 @@ function normalizeRootOptions(
|
|
|
115
117
|
return { ...view, children: [mark] };
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
function typeCtor(
|
|
120
|
+
function typeCtor(
|
|
121
|
+
type: string | ((...args: any[]) => any),
|
|
122
|
+
mark: Record<string, new () => Node>,
|
|
123
|
+
composition: Record<string, new () => Node>,
|
|
124
|
+
): new () => Node {
|
|
119
125
|
if (typeof type === 'function') return mark.mark;
|
|
120
126
|
const node = { ...mark, ...composition };
|
|
121
127
|
const ctor = node[type];
|
|
@@ -124,9 +130,13 @@ function typeCtor(type: string | ((...args: any[]) => any)): new () => Node {
|
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
// Create node from options.
|
|
127
|
-
function createNode(
|
|
133
|
+
function createNode(
|
|
134
|
+
options: G2ViewTree,
|
|
135
|
+
mark: Record<string, new () => Node>,
|
|
136
|
+
composition: Record<string, new () => Node>,
|
|
137
|
+
): Node {
|
|
128
138
|
const { type, children, ...value } = options;
|
|
129
|
-
const Ctor = typeCtor(type);
|
|
139
|
+
const Ctor = typeCtor(type, mark, composition);
|
|
130
140
|
const node = new Ctor();
|
|
131
141
|
node.value = value;
|
|
132
142
|
// @ts-ignore
|
|
@@ -148,12 +158,17 @@ function updateNode(node: Node, newOptions: G2ViewTree) {
|
|
|
148
158
|
}
|
|
149
159
|
|
|
150
160
|
// Create a nested node tree from newOptions, and append it to the parent.
|
|
151
|
-
function appendNode(
|
|
161
|
+
function appendNode(
|
|
162
|
+
parent: Node,
|
|
163
|
+
newOptions: G2ViewTree,
|
|
164
|
+
mark: Record<string, new () => Node>,
|
|
165
|
+
composition: Record<string, new () => Node>,
|
|
166
|
+
) {
|
|
152
167
|
if (!parent) return;
|
|
153
168
|
const discovered = [[parent, newOptions]];
|
|
154
169
|
while (discovered.length) {
|
|
155
170
|
const [parent, nodeOptions] = discovered.shift();
|
|
156
|
-
const node = createNode(nodeOptions);
|
|
171
|
+
const node = createNode(nodeOptions, mark, composition);
|
|
157
172
|
if (Array.isArray(parent.children)) parent.push(node);
|
|
158
173
|
const { children } = nodeOptions;
|
|
159
174
|
if (Array.isArray(children)) {
|
|
@@ -169,14 +184,16 @@ export function updateRoot(
|
|
|
169
184
|
node: Node,
|
|
170
185
|
options: G2ViewTree,
|
|
171
186
|
definedType: string,
|
|
187
|
+
mark: Record<string, new () => Node>,
|
|
188
|
+
composition: Record<string, new () => Node>,
|
|
172
189
|
) {
|
|
173
|
-
const rootOptions = normalizeRootOptions(node, options, definedType);
|
|
190
|
+
const rootOptions = normalizeRootOptions(node, options, definedType, mark);
|
|
174
191
|
const discovered: [Node, Node, G2ViewTree][] = [[null, node, rootOptions]];
|
|
175
192
|
while (discovered.length) {
|
|
176
193
|
const [parent, oldNode, newNode] = discovered.shift();
|
|
177
194
|
// If there is no oldNode, create a node tree directly.
|
|
178
195
|
if (!oldNode) {
|
|
179
|
-
appendNode(parent, newNode);
|
|
196
|
+
appendNode(parent, newNode, mark, composition);
|
|
180
197
|
} else if (!newNode) {
|
|
181
198
|
oldNode.remove();
|
|
182
199
|
} else {
|
package/src/component/axis.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Coordinate } from '@antv/coord';
|
|
|
2
2
|
import type { DisplayObject } from '@antv/g';
|
|
3
3
|
import { Axis as AxisComponent } from '@antv/gui';
|
|
4
4
|
import { Linear as LinearScale } from '@antv/scale';
|
|
5
|
-
import { deepMix,
|
|
5
|
+
import { deepMix, omit } from '@antv/util';
|
|
6
6
|
import { extent } from 'd3-array';
|
|
7
7
|
import { format } from 'd3-format';
|
|
8
8
|
import {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
radiusOf,
|
|
25
25
|
} from '../utils/coordinate';
|
|
26
26
|
import { capitalizeFirst } from '../utils/helper';
|
|
27
|
+
import { isOrdinalScale } from '../utils/scale';
|
|
27
28
|
import { adaptor, isVertical, titleContent } from './utils';
|
|
28
29
|
|
|
29
30
|
export type AxisOptions = {
|
|
@@ -157,6 +158,7 @@ function getData(
|
|
|
157
158
|
const applyFisheye = createFisheye(position, coordinate);
|
|
158
159
|
const isHorizontal = (position) =>
|
|
159
160
|
['top', 'bottom', 'center', 'outer'].includes(position);
|
|
161
|
+
const isVertical = (position) => ['left', 'right'].includes(position);
|
|
160
162
|
|
|
161
163
|
// @todo GUI should consider the overlap problem for the first
|
|
162
164
|
// and label of arc axis.
|
|
@@ -168,7 +170,9 @@ function getData(
|
|
|
168
170
|
(isRadial(coordinate) && position === 'center') ||
|
|
169
171
|
(isTranspose(coordinate) &&
|
|
170
172
|
scale.getTicks?.() &&
|
|
171
|
-
isHorizontal(position))
|
|
173
|
+
isHorizontal(position)) ||
|
|
174
|
+
(isTranspose(coordinate) && isVertical(position));
|
|
175
|
+
|
|
172
176
|
return {
|
|
173
177
|
value: shouldReverse ? 1 - tick : tick,
|
|
174
178
|
label: toString(labelFormatter(prettyNumber(d), i, array)),
|
|
@@ -180,8 +184,9 @@ function getData(
|
|
|
180
184
|
return filteredTicks.map((d, i, array) => {
|
|
181
185
|
const offset = scale.getBandWidth?.(d) / 2 || 0;
|
|
182
186
|
const tick = applyFisheye(applyInset(scale.map(d) + offset));
|
|
187
|
+
const shouldReverse = isVertical(position);
|
|
183
188
|
return {
|
|
184
|
-
value: tick,
|
|
189
|
+
value: shouldReverse ? 1 - tick : tick,
|
|
185
190
|
label: toString(labelFormatter(prettyNumber(d), i, array)),
|
|
186
191
|
id: String(i),
|
|
187
192
|
};
|
|
@@ -291,10 +296,10 @@ function inferAxisLinearOverrideStyle(
|
|
|
291
296
|
return { startPos: [x, y], endPos: [x + width, y] };
|
|
292
297
|
}
|
|
293
298
|
if (position === 'left') {
|
|
294
|
-
return { startPos: [x + width, y], endPos: [x + width, y
|
|
299
|
+
return { startPos: [x + width, y + height], endPos: [x + width, y] };
|
|
295
300
|
}
|
|
296
301
|
if (position === 'right') {
|
|
297
|
-
return {
|
|
302
|
+
return { startPos: [x, y + height], endPos: [x, y] };
|
|
298
303
|
}
|
|
299
304
|
if (position === 'top') {
|
|
300
305
|
return { startPos: [x, y + height], endPos: [x + width, y + height] };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Coordinate } from '@antv/coord';
|
|
2
1
|
import type { DisplayObject } from '@antv/g';
|
|
3
2
|
import { Category } from '@antv/gui';
|
|
4
3
|
import { last } from '@antv/util';
|
|
@@ -83,19 +82,18 @@ function inferItemMarker(
|
|
|
83
82
|
context: GuideComponentContext,
|
|
84
83
|
): ((datum: any, i: number, data: any) => () => DisplayObject) | undefined {
|
|
85
84
|
const { scales, library, markState } = context;
|
|
86
|
-
const [
|
|
87
|
-
|
|
85
|
+
const [mark, shapes] = inferShape(scales, markState);
|
|
88
86
|
const { itemMarker, itemMarkerSize: size } = options;
|
|
89
87
|
|
|
90
88
|
const create = (name, d) => {
|
|
91
89
|
const marker =
|
|
92
|
-
(library[`
|
|
93
|
-
|
|
90
|
+
(library[`mark.${mark}`]?.props?.shape[name]?.props
|
|
91
|
+
.defaultMarker as string) || last(name.split('.'));
|
|
94
92
|
const radius = typeof size === 'function' ? size(d) : size;
|
|
95
93
|
return () => useMarker(marker, { color: d.color })(0, 0, radius);
|
|
96
94
|
};
|
|
97
95
|
|
|
98
|
-
const shapeOf = (i) => `${
|
|
96
|
+
const shapeOf = (i) => `${shapes[i]}`;
|
|
99
97
|
|
|
100
98
|
const shapeScale = scaleOf(scales, 'shape');
|
|
101
99
|
if (shapeScale && !itemMarker) return (d, i) => create(shapeOf(i), d);
|
|
@@ -184,7 +184,7 @@ export const GeoView: CC<GeoViewOptions> = () => {
|
|
|
184
184
|
});
|
|
185
185
|
const normalize = (point) => {
|
|
186
186
|
const visualPoint = visual(point);
|
|
187
|
-
if (!visualPoint) return null;
|
|
187
|
+
if (!visualPoint) return [null, null];
|
|
188
188
|
const [vx, vy] = visualPoint;
|
|
189
189
|
return [scaleX.map(vx), scaleY.map(vy)];
|
|
190
190
|
};
|
package/src/composition/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { FacetRect } from './facetRect';
|
|
|
6
6
|
export { RepeatMatrix } from './repeatMatrix';
|
|
7
7
|
export { FacetCircle } from './facetCircle';
|
|
8
8
|
export { TimingKeyframe } from './timingKeyframe';
|
|
9
|
+
export { GeoPath } from './geoPath';
|
|
10
|
+
export { GeoView } from './geoView';
|
|
9
11
|
|
|
10
12
|
export type { SpaceLayerOptions } from './spaceLayer';
|
|
11
13
|
export type { SpaceFlexOptions } from './spaceFlex';
|
package/src/data/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { Join } from './join';
|
|
|
17
17
|
export { Slice } from './slice';
|
|
18
18
|
export { KDE } from './kde';
|
|
19
19
|
export { Venn } from './venn';
|
|
20
|
+
export { Log } from './log';
|
|
20
21
|
|
|
21
22
|
export type { FetchOptions } from './fetch';
|
|
22
23
|
export type { FoldOptions } from './fold';
|
|
@@ -37,3 +38,4 @@ export type { JoinOptions } from './join';
|
|
|
37
38
|
export type { SliceOptions } from './slice';
|
|
38
39
|
export type { KDEOptions } from './kde';
|
|
39
40
|
export type { VennOptions } from './venn';
|
|
41
|
+
export type { LogDataOptions } from './log';
|
package/src/data/log.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataComponent as DC } from '../runtime';
|
|
2
|
+
import { LogDataTransform } from '../spec';
|
|
3
|
+
|
|
4
|
+
export type LogDataOptions = Omit<LogDataTransform, 'type'>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Console.log the data section for dev debugger.
|
|
8
|
+
*/
|
|
9
|
+
export const Log: DC<LogDataOptions> = () => {
|
|
10
|
+
return (data) => {
|
|
11
|
+
console.log('G2 data section:', data);
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
Log.props = {};
|
package/src/index.ts
CHANGED
|
@@ -15,12 +15,21 @@ export {
|
|
|
15
15
|
AREA_CLASS_NAME,
|
|
16
16
|
} from './runtime';
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export { corelib, stdlib, litelib } from './lib';
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export * from './mark';
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export {
|
|
23
|
+
Chart,
|
|
24
|
+
MarkNode,
|
|
25
|
+
CompositionNode,
|
|
26
|
+
register,
|
|
27
|
+
Runtime,
|
|
28
|
+
extend,
|
|
29
|
+
} from './api';
|
|
23
30
|
|
|
24
31
|
export { ChartEvent } from './utils/event';
|
|
25
32
|
|
|
33
|
+
export type { G2Context } from './runtime';
|
|
34
|
+
|
|
26
35
|
export * from './spec';
|
|
@@ -82,7 +82,7 @@ export function brushFilter(
|
|
|
82
82
|
|
|
83
83
|
export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
|
|
84
84
|
return (target, viewInstances, emitter) => {
|
|
85
|
-
const { container, view, options: viewOptions, update } = target;
|
|
85
|
+
const { container, view, options: viewOptions, update, setState } = target;
|
|
86
86
|
const plotArea = selectPlotArea(container);
|
|
87
87
|
const defaultOptions = {
|
|
88
88
|
maskFill: '#777',
|
|
@@ -110,26 +110,35 @@ export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
|
|
|
110
110
|
|
|
111
111
|
// Update the domain of x and y scale to filter data.
|
|
112
112
|
const [domainX, domainY] = selection;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
|
|
114
|
+
setState('brushFilter', (options) => {
|
|
115
|
+
const { marks } = options;
|
|
116
|
+
const newMarks = marks.map((mark) =>
|
|
117
|
+
deepMix(
|
|
118
|
+
{
|
|
119
|
+
// Hide label to keep smooth transition.
|
|
120
|
+
axis: {
|
|
121
|
+
...(hideX && { x: { transform: [{ type: 'hide' }] } }),
|
|
122
|
+
...(hideY && { y: { transform: [{ type: 'hide' }] } }),
|
|
123
|
+
},
|
|
121
124
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
mark,
|
|
126
|
+
{
|
|
127
|
+
// Set nice to false to avoid modify domain.
|
|
128
|
+
scale: {
|
|
129
|
+
x: { domain: domainX, nice: false },
|
|
130
|
+
y: { domain: domainY, nice: false },
|
|
131
|
+
},
|
|
129
132
|
},
|
|
130
|
-
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
...viewOptions,
|
|
138
|
+
marks: newMarks,
|
|
139
|
+
clip: true, // Clip shapes out of plot area.
|
|
140
|
+
};
|
|
141
|
+
});
|
|
133
142
|
|
|
134
143
|
// Emit event.
|
|
135
144
|
emitter.emit('brush:filter', {
|
|
@@ -137,13 +146,7 @@ export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
|
|
|
137
146
|
data: { selection: [domainX, domainY] },
|
|
138
147
|
});
|
|
139
148
|
|
|
140
|
-
|
|
141
|
-
const newOptions = {
|
|
142
|
-
...viewOptions,
|
|
143
|
-
marks: newMarks,
|
|
144
|
-
clip: true, // Clip shapes out of plot area.
|
|
145
|
-
};
|
|
146
|
-
const newState = await update(newOptions);
|
|
149
|
+
const newState = await update();
|
|
147
150
|
newView = newState.view;
|
|
148
151
|
filtering = false;
|
|
149
152
|
filtered = true;
|
|
@@ -160,10 +163,10 @@ export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
|
|
|
160
163
|
...event,
|
|
161
164
|
data: { selection: [domainX, domainY] },
|
|
162
165
|
});
|
|
163
|
-
|
|
164
166
|
filtered = false;
|
|
165
167
|
newView = view;
|
|
166
|
-
|
|
168
|
+
setState('brushFilter');
|
|
169
|
+
update();
|
|
167
170
|
},
|
|
168
171
|
extent: undefined,
|
|
169
172
|
emitter,
|
|
@@ -58,7 +58,7 @@ export function ChartIndex({
|
|
|
58
58
|
...style
|
|
59
59
|
}: Record<string, any>) {
|
|
60
60
|
return (context) => {
|
|
61
|
-
const {
|
|
61
|
+
const { view, container, update, setState } = context;
|
|
62
62
|
const { markState, scale, coordinate } = view;
|
|
63
63
|
|
|
64
64
|
// Get line mark value, exit if it is not existed.
|
|
@@ -70,18 +70,6 @@ export function ChartIndex({
|
|
|
70
70
|
const I = Y.map((_, i) => i);
|
|
71
71
|
const sortedX: number[] = sort(I.map((i) => X[i]));
|
|
72
72
|
|
|
73
|
-
// Clone options and get line mark.
|
|
74
|
-
const clonedOptions = deepMix({}, options);
|
|
75
|
-
const lineMark = clonedOptions.marks.find((d) => d.type === 'line');
|
|
76
|
-
|
|
77
|
-
// Update domain of y scale for the line mark.
|
|
78
|
-
const r = (I: number[]) => max(I, (i) => +Y[i]) / min(I, (i) => +Y[i]);
|
|
79
|
-
const k = max(rollup(I, r, (i) => S[i]).values());
|
|
80
|
-
const domainY = [1 / k, k];
|
|
81
|
-
deepMix(lineMark, {
|
|
82
|
-
scale: { y: { domain: domainY } },
|
|
83
|
-
});
|
|
84
|
-
|
|
85
73
|
// Prepare shapes.
|
|
86
74
|
const plotArea = selectPlotArea(container);
|
|
87
75
|
const lines = container.getElementsByClassName(ELEMENT_CLASS_NAME);
|
|
@@ -142,16 +130,31 @@ export function ChartIndex({
|
|
|
142
130
|
|
|
143
131
|
updateRule(focus, date);
|
|
144
132
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
133
|
+
setState('chartIndex', (options) => {
|
|
134
|
+
// Clone options and get line mark.
|
|
135
|
+
const clonedOptions = deepMix({}, options);
|
|
136
|
+
const lineMark = clonedOptions.marks.find((d) => d.type === 'line');
|
|
137
|
+
|
|
138
|
+
// Update domain of y scale for the line mark.
|
|
139
|
+
const r = (I: number[]) => max(I, (i) => +Y[i]) / min(I, (i) => +Y[i]);
|
|
140
|
+
const k = max(rollup(I, r, (i) => S[i]).values());
|
|
141
|
+
const domainY = [1 / k, k];
|
|
142
|
+
deepMix(lineMark, {
|
|
143
|
+
scale: { y: { domain: domainY } },
|
|
144
|
+
});
|
|
145
|
+
// Update normalize options.
|
|
146
|
+
const normalizeY = maybeTransform(lineMark);
|
|
147
|
+
normalizeY.groupBy = 'color';
|
|
148
|
+
normalizeY.basis = (I, Y) => {
|
|
149
|
+
const i = I[bisector((i) => X[+i]).center(I, date)];
|
|
150
|
+
return Y[i];
|
|
151
|
+
};
|
|
152
|
+
// Disable animation.
|
|
153
|
+
for (const mark of clonedOptions.marks) mark.animate = false;
|
|
154
|
+
return clonedOptions;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const newState = await update();
|
|
155
158
|
newView = newState.view;
|
|
156
159
|
};
|
|
157
160
|
|
|
@@ -22,26 +22,30 @@ export function Fisheye({
|
|
|
22
22
|
trailing = false,
|
|
23
23
|
}: Record<string, any>) {
|
|
24
24
|
return (context) => {
|
|
25
|
-
const { options, update, container } = context;
|
|
25
|
+
const { options, update, setState, container } = context;
|
|
26
26
|
const plotArea = selectPlotArea(container);
|
|
27
27
|
|
|
28
|
-
// Clone options and mutate it.
|
|
29
|
-
// Disable animation.
|
|
30
|
-
const clonedOptions = deepMix({}, options);
|
|
31
|
-
for (const mark of clonedOptions.marks) mark.animate = false;
|
|
32
28
|
const updateFocus = throttle(
|
|
33
29
|
(event) => {
|
|
34
30
|
const focus = mousePosition(plotArea, event);
|
|
35
31
|
if (!focus) {
|
|
36
|
-
|
|
32
|
+
setState('fisheye');
|
|
33
|
+
update();
|
|
37
34
|
return;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
setState('fisheye', (options) => {
|
|
37
|
+
// Clone options and mutate it.
|
|
38
|
+
// Disable animation.
|
|
39
|
+
const clonedOptions = deepMix({}, options);
|
|
40
|
+
for (const mark of clonedOptions.marks) mark.animate = false;
|
|
41
|
+
const [x, y] = focus;
|
|
42
|
+
const fisheye = maybeCoordinate(clonedOptions);
|
|
43
|
+
fisheye.focusX = x;
|
|
44
|
+
fisheye.focusY = y;
|
|
45
|
+
fisheye.visual = true;
|
|
46
|
+
return clonedOptions;
|
|
47
|
+
});
|
|
48
|
+
update();
|
|
45
49
|
},
|
|
46
50
|
wait,
|
|
47
51
|
{ leading, trailing },
|
|
@@ -200,52 +200,57 @@ function legendFilterContinuous(_, { legend, filter, emitter, channel }) {
|
|
|
200
200
|
|
|
201
201
|
export function LegendFilter() {
|
|
202
202
|
return (context, _, emitter) => {
|
|
203
|
-
const { container, view,
|
|
203
|
+
const { container, view, update, setState } = context;
|
|
204
204
|
|
|
205
|
+
const channelsOf = (legend) => {
|
|
206
|
+
return dataOf(legend).scales.map((d) => d.name);
|
|
207
|
+
};
|
|
205
208
|
const legends = [
|
|
206
209
|
...legendsOf(container),
|
|
207
210
|
...legendsContinuousOf(container),
|
|
208
211
|
];
|
|
212
|
+
const allChannels = legends.flatMap(channelsOf);
|
|
209
213
|
|
|
210
214
|
const filter = throttle(
|
|
211
|
-
async (channel, value, ordinal: boolean, channels) => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
channel
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
215
|
+
async (legend, channel, value, ordinal: boolean, channels) => {
|
|
216
|
+
setState(legend, (viewOptions) => {
|
|
217
|
+
const { marks } = viewOptions;
|
|
218
|
+
// Add filter transform for every marks,
|
|
219
|
+
// which will skip for mark without color channel.
|
|
220
|
+
const newMarks = marks.map((mark) => {
|
|
221
|
+
if (mark.type === 'legends') return mark;
|
|
222
|
+
|
|
223
|
+
// Inset after aggregate transform, such as group, and bin.
|
|
224
|
+
const { transform = [] } = mark;
|
|
225
|
+
const index = transform.findIndex(
|
|
226
|
+
({ type }) => type.startsWith('group') || type.startsWith('bin'),
|
|
227
|
+
);
|
|
228
|
+
const newTransform = [...transform];
|
|
229
|
+
newTransform.splice(index + 1, 0, {
|
|
230
|
+
type: 'filter',
|
|
231
|
+
[channel]: { value, ordinal },
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Set domain of scale to preserve encoding.
|
|
235
|
+
const newScale = Object.fromEntries(
|
|
236
|
+
channels.map((channel) => [
|
|
237
|
+
channel,
|
|
238
|
+
{ domain: view.scale[channel].getOptions().domain },
|
|
239
|
+
]),
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return deepMix({}, mark, {
|
|
243
|
+
transform: newTransform,
|
|
244
|
+
scale: newScale,
|
|
245
|
+
...(!ordinal && { animate: false }),
|
|
246
|
+
legend: Object.fromEntries(
|
|
247
|
+
allChannels.map((d) => [d, { preserve: true }]),
|
|
248
|
+
),
|
|
249
|
+
});
|
|
242
250
|
});
|
|
251
|
+
return { ...viewOptions, marks: newMarks };
|
|
243
252
|
});
|
|
244
|
-
|
|
245
|
-
...viewOptions,
|
|
246
|
-
marks: newMarks,
|
|
247
|
-
};
|
|
248
|
-
await update(newOptions);
|
|
253
|
+
await update();
|
|
249
254
|
},
|
|
250
255
|
50,
|
|
251
256
|
{ trailing: true },
|
|
@@ -253,7 +258,7 @@ export function LegendFilter() {
|
|
|
253
258
|
|
|
254
259
|
const removes = legends.map((legend) => {
|
|
255
260
|
const { name: channel, domain } = dataOf(legend).scales[0];
|
|
256
|
-
const channels =
|
|
261
|
+
const channels = channelsOf(legend);
|
|
257
262
|
if (legend.className === CATEGORY_LEGEND_CLASS_NAME) {
|
|
258
263
|
return legendFilterOrdinal(container, {
|
|
259
264
|
legends: itemsOf,
|
|
@@ -264,7 +269,7 @@ export function LegendFilter() {
|
|
|
264
269
|
const { index } = datum;
|
|
265
270
|
return domain[index];
|
|
266
271
|
},
|
|
267
|
-
filter: (value) => filter(channel, value, true, channels),
|
|
272
|
+
filter: (value) => filter(legend, channel, value, true, channels),
|
|
268
273
|
state: legend.attributes.state,
|
|
269
274
|
channel,
|
|
270
275
|
emitter,
|
|
@@ -272,7 +277,7 @@ export function LegendFilter() {
|
|
|
272
277
|
} else {
|
|
273
278
|
return legendFilterContinuous(container, {
|
|
274
279
|
legend,
|
|
275
|
-
filter: (value) => filter(channel, value, false, channels),
|
|
280
|
+
filter: (value) => filter(legend, channel, value, false, channels),
|
|
276
281
|
emitter,
|
|
277
282
|
channel,
|
|
278
283
|
});
|
|
@@ -68,7 +68,7 @@ export function SliderFilter({
|
|
|
68
68
|
trailing = false,
|
|
69
69
|
}: any) {
|
|
70
70
|
return (context, _, emitter) => {
|
|
71
|
-
const { container, view,
|
|
71
|
+
const { container, view, update, setState } = context;
|
|
72
72
|
const sliders = container.getElementsByClassName(className);
|
|
73
73
|
if (!sliders.length) return () => {};
|
|
74
74
|
|
|
@@ -138,18 +138,6 @@ export function SliderFilter({
|
|
|
138
138
|
channelDomain[channel0] = domain0;
|
|
139
139
|
channelDomain[channel1] = domain1;
|
|
140
140
|
|
|
141
|
-
// Filter data.
|
|
142
|
-
const newOptions = filterDataByDomain(
|
|
143
|
-
options,
|
|
144
|
-
{
|
|
145
|
-
// Set nice to false to avoid modify domain.
|
|
146
|
-
[channel0]: { domain: domain0, nice: false },
|
|
147
|
-
[channel1]: { domain: domain1, nice: false },
|
|
148
|
-
},
|
|
149
|
-
prefix,
|
|
150
|
-
hasState,
|
|
151
|
-
);
|
|
152
|
-
|
|
153
141
|
if (nativeEvent) {
|
|
154
142
|
// Emit events.
|
|
155
143
|
const X = isX ? domain0 : domain1;
|
|
@@ -161,13 +149,24 @@ export function SliderFilter({
|
|
|
161
149
|
});
|
|
162
150
|
}
|
|
163
151
|
|
|
164
|
-
|
|
165
|
-
...
|
|
152
|
+
setState(slider, (options) => ({
|
|
153
|
+
...filterDataByDomain(
|
|
154
|
+
options,
|
|
155
|
+
{
|
|
156
|
+
// Set nice to false to avoid modify domain.
|
|
157
|
+
[channel0]: { domain: domain0, nice: false },
|
|
158
|
+
[channel1]: { domain: domain1, nice: false },
|
|
159
|
+
},
|
|
160
|
+
prefix,
|
|
161
|
+
hasState,
|
|
162
|
+
),
|
|
166
163
|
paddingLeft,
|
|
167
164
|
paddingTop,
|
|
168
165
|
paddingBottom,
|
|
169
166
|
paddingRight,
|
|
170
|
-
});
|
|
167
|
+
}));
|
|
168
|
+
|
|
169
|
+
await update();
|
|
171
170
|
filtering = false;
|
|
172
171
|
},
|
|
173
172
|
wait,
|