@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/chart.ts
CHANGED
|
@@ -1,344 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Plugin as DragAndDropPlugin } from '@antv/g-plugin-dragndrop';
|
|
4
|
-
import { debounce } from '@antv/util';
|
|
5
|
-
import EventEmitter from '@antv/event-emitter';
|
|
6
|
-
import { G2Context, render, destroy } from '../runtime';
|
|
7
|
-
import { ViewComposition } from '../spec';
|
|
8
|
-
import { ChartEvent } from '../utils/event';
|
|
9
|
-
import { G2ViewTree } from '../runtime/types/options';
|
|
10
|
-
import {
|
|
11
|
-
defineProps,
|
|
12
|
-
NodePropertyDescriptor,
|
|
13
|
-
nodeProps,
|
|
14
|
-
containerProps,
|
|
15
|
-
} from './props';
|
|
16
|
-
import {
|
|
17
|
-
ValueAttribute,
|
|
18
|
-
Concrete,
|
|
19
|
-
ArrayAttribute,
|
|
20
|
-
ObjectAttribute,
|
|
21
|
-
} from './types';
|
|
22
|
-
import { mark, Mark } from './mark';
|
|
23
|
-
import { composition, Composition, View } from './composition';
|
|
1
|
+
import { G2Spec } from '../spec';
|
|
2
|
+
import { extend, API } from './extend';
|
|
24
3
|
import { library } from './library';
|
|
25
|
-
import {
|
|
26
|
-
normalizeContainer,
|
|
27
|
-
removeContainer,
|
|
28
|
-
sizeOf,
|
|
29
|
-
optionsOf,
|
|
30
|
-
updateRoot,
|
|
31
|
-
createEmptyPromise,
|
|
32
|
-
} from './utils';
|
|
4
|
+
import { Runtime } from './runtime';
|
|
33
5
|
|
|
34
|
-
export
|
|
6
|
+
export interface Chart extends API<G2Spec, typeof library> {}
|
|
35
7
|
|
|
36
|
-
export
|
|
37
|
-
container?: string | HTMLElement;
|
|
38
|
-
canvas?: GCanvas;
|
|
39
|
-
width?: number;
|
|
40
|
-
height?: number;
|
|
41
|
-
autoFit?: boolean;
|
|
42
|
-
renderer?: IRenderer;
|
|
43
|
-
plugins?: RendererPlugin[];
|
|
44
|
-
theme?: string;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type ChartProps = Concrete<ViewComposition>;
|
|
48
|
-
|
|
49
|
-
export interface Chart extends Composition, Mark {
|
|
50
|
-
data: ValueAttribute<ChartProps['data'], Chart>;
|
|
51
|
-
width: ValueAttribute<ChartProps['width'], Chart>;
|
|
52
|
-
height: ValueAttribute<ChartProps['height'], Chart>;
|
|
53
|
-
coordinate: ValueAttribute<ChartProps['coordinate'], Chart>;
|
|
54
|
-
interaction: ObjectAttribute<ChartProps['interaction'], Chart>;
|
|
55
|
-
key: ValueAttribute<ChartProps['key'], Chart>;
|
|
56
|
-
transform: ArrayAttribute<ChartProps['transform'], Chart>;
|
|
57
|
-
theme: ObjectAttribute<ChartProps['theme'], Chart>;
|
|
58
|
-
title: ValueAttribute<ChartProps['title'], Chart>;
|
|
59
|
-
scale: ObjectAttribute<ChartOptions['scale'], Chart>;
|
|
60
|
-
axis: ObjectAttribute<ChartOptions['axis'], Chart>;
|
|
61
|
-
legend: ObjectAttribute<ChartOptions['legend'], Chart>;
|
|
62
|
-
style: ObjectAttribute<ChartOptions['style'], Chart>;
|
|
63
|
-
labelTransform: ArrayAttribute<ChartOptions['labelTransform'], Chart>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const props: NodePropertyDescriptor[] = [
|
|
67
|
-
{ name: 'data', type: 'value' },
|
|
68
|
-
{ name: 'width', type: 'value' },
|
|
69
|
-
{ name: 'height', type: 'value' },
|
|
70
|
-
{ name: 'coordinate', type: 'value' },
|
|
71
|
-
{ name: 'interaction', type: 'object' },
|
|
72
|
-
{ name: 'theme', type: 'object' },
|
|
73
|
-
{ name: 'title', type: 'value' },
|
|
74
|
-
{ name: 'transform', type: 'array' },
|
|
75
|
-
{ name: 'scale', type: 'object' },
|
|
76
|
-
{ name: 'axis', type: 'object' },
|
|
77
|
-
{ name: 'legend', type: 'object' },
|
|
78
|
-
{ name: 'style', type: 'object' },
|
|
79
|
-
{ name: 'labelTransform', type: 'array' },
|
|
80
|
-
...nodeProps(mark),
|
|
81
|
-
...containerProps(composition),
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
@defineProps(props)
|
|
85
|
-
export class Chart extends View<ChartOptions> {
|
|
86
|
-
private _container: HTMLElement;
|
|
87
|
-
private _context: G2Context;
|
|
88
|
-
private _emitter: EventEmitter;
|
|
89
|
-
private _width: number;
|
|
90
|
-
private _height: number;
|
|
91
|
-
private _renderer: IRenderer;
|
|
92
|
-
private _plugins: RendererPlugin[];
|
|
93
|
-
// Identifies whether bindAutoFit.
|
|
94
|
-
private _hasBindAutoFit = false;
|
|
95
|
-
private _rendering = false;
|
|
96
|
-
private _trailing = false;
|
|
97
|
-
private _trailingResolve = null;
|
|
98
|
-
private _trailingReject = null;
|
|
99
|
-
private _previousDefinedType = null;
|
|
100
|
-
|
|
101
|
-
constructor(options: ChartOptions) {
|
|
102
|
-
const { container, canvas, renderer, plugins, ...rest } = options || {};
|
|
103
|
-
super(rest, 'view');
|
|
104
|
-
this._renderer = renderer || new CanvasRenderer();
|
|
105
|
-
this._plugins = plugins || [];
|
|
106
|
-
this._container = normalizeContainer(container);
|
|
107
|
-
this._emitter = new EventEmitter();
|
|
108
|
-
this._context = { library, emitter: this._emitter, canvas };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
render(): Promise<Chart> {
|
|
112
|
-
if (this._rendering) return this._addToTrailing();
|
|
113
|
-
if (!this._context.canvas) this._createCanvas();
|
|
114
|
-
this._bindAutoFit();
|
|
115
|
-
this._rendering = true;
|
|
116
|
-
const finished = new Promise<Chart>((resolve, reject) =>
|
|
117
|
-
render(
|
|
118
|
-
this._computedOptions(),
|
|
119
|
-
this._context,
|
|
120
|
-
this._createResolve(resolve),
|
|
121
|
-
this._createReject(reject),
|
|
122
|
-
),
|
|
123
|
-
);
|
|
124
|
-
const [finished1, resolve, reject] = createEmptyPromise<Chart>();
|
|
125
|
-
finished
|
|
126
|
-
.then(resolve)
|
|
127
|
-
.catch(reject)
|
|
128
|
-
.then(() => this._renderTrailing());
|
|
129
|
-
return finished1;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @overload
|
|
134
|
-
* @returns {G2ViewTree}
|
|
135
|
-
*/
|
|
136
|
-
options(): G2ViewTree;
|
|
137
|
-
/**
|
|
138
|
-
* @overload
|
|
139
|
-
* @param {G2ViewTree} options
|
|
140
|
-
* @returns {Chart}
|
|
141
|
-
*/
|
|
142
|
-
options(options: G2ViewTree): Chart;
|
|
143
|
-
/**
|
|
144
|
-
* @overload
|
|
145
|
-
* @param {G2ViewTree} [options]
|
|
146
|
-
* @returns {Chart|G2ViewTree}
|
|
147
|
-
*/
|
|
148
|
-
options(options?: G2ViewTree): Chart | G2ViewTree {
|
|
149
|
-
if (arguments.length === 0) return optionsOf(this);
|
|
150
|
-
const { type } = options;
|
|
151
|
-
if (type) this._previousDefinedType = type;
|
|
152
|
-
updateRoot(this, options, this._previousDefinedType);
|
|
153
|
-
return this;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
getContainer(): HTMLElement {
|
|
157
|
-
return this._container;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
getContext(): G2Context {
|
|
161
|
-
return this._context;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
on(event: string, callback: (...args: any[]) => any, once?: boolean): this {
|
|
165
|
-
this._emitter.on(event, callback, once);
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
once(event: string, callback: (...args: any[]) => any): this {
|
|
170
|
-
this._emitter.once(event, callback);
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
emit(event: string, ...args: any[]): this {
|
|
175
|
-
this._emitter.emit(event, ...args);
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
off(event?: string, callback?: (...args: any[]) => any) {
|
|
180
|
-
this._emitter.off(event, callback);
|
|
181
|
-
return this;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
clear() {
|
|
185
|
-
const options = this.options();
|
|
186
|
-
this.emit(ChartEvent.BEFORE_CLEAR);
|
|
187
|
-
this._reset();
|
|
188
|
-
destroy(options, this._context, false);
|
|
189
|
-
this.emit(ChartEvent.AFTER_CLEAR);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
destroy() {
|
|
193
|
-
const options = this.options();
|
|
194
|
-
this.emit(ChartEvent.BEFORE_DESTROY);
|
|
195
|
-
this._unbindAutoFit();
|
|
196
|
-
this._reset();
|
|
197
|
-
destroy(options, this._context, true);
|
|
198
|
-
removeContainer(this._container);
|
|
199
|
-
this.emit(ChartEvent.AFTER_DESTROY);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
forceFit() {
|
|
203
|
-
// Don't fit if size do not change.
|
|
204
|
-
this.options['autoFit'] = true;
|
|
205
|
-
const { width, height } = sizeOf(this.options(), this._container);
|
|
206
|
-
if (width === this._width && height === this._height) {
|
|
207
|
-
return Promise.resolve(this);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Don't call changeSize to prevent update width and height of options.
|
|
211
|
-
this.emit(ChartEvent.BEFORE_CHANGE_SIZE);
|
|
212
|
-
const finished = this.render();
|
|
213
|
-
finished.then(() => {
|
|
214
|
-
this.emit(ChartEvent.AFTER_CHANGE_SIZE);
|
|
215
|
-
});
|
|
216
|
-
return finished;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
changeSize(width: number, height: number): Promise<Chart> {
|
|
220
|
-
if (width === this._width && height === this._height) {
|
|
221
|
-
return Promise.resolve(this);
|
|
222
|
-
}
|
|
223
|
-
this.emit(ChartEvent.BEFORE_CHANGE_SIZE);
|
|
224
|
-
this.width(width);
|
|
225
|
-
this.height(height);
|
|
226
|
-
const finished = this.render();
|
|
227
|
-
finished.then(() => {
|
|
228
|
-
this.emit(ChartEvent.AFTER_CHANGE_SIZE);
|
|
229
|
-
});
|
|
230
|
-
return finished;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private _reset() {
|
|
234
|
-
const KEYS = ['theme', 'type', 'width', 'height', 'autoFit'];
|
|
235
|
-
this.type = 'view';
|
|
236
|
-
this.value = Object.fromEntries(
|
|
237
|
-
Object.entries(this.value).filter(
|
|
238
|
-
([key]) =>
|
|
239
|
-
key.startsWith('margin') ||
|
|
240
|
-
key.startsWith('padding') ||
|
|
241
|
-
key.startsWith('inset') ||
|
|
242
|
-
KEYS.includes(key),
|
|
243
|
-
),
|
|
244
|
-
);
|
|
245
|
-
this.children = [];
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
private _renderTrailing() {
|
|
249
|
-
if (!this._trailing) return;
|
|
250
|
-
this._trailing = false;
|
|
251
|
-
this.render()
|
|
252
|
-
.then(() => {
|
|
253
|
-
const trailingResolve = this._trailingResolve.bind(this);
|
|
254
|
-
this._trailingResolve = null;
|
|
255
|
-
trailingResolve(this);
|
|
256
|
-
})
|
|
257
|
-
.catch((error) => {
|
|
258
|
-
const trailingReject = this._trailingReject.bind(this);
|
|
259
|
-
this._trailingReject = null;
|
|
260
|
-
trailingReject(error);
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
private _createResolve(resolve: (chart: Chart) => void) {
|
|
265
|
-
return () => {
|
|
266
|
-
this._rendering = false;
|
|
267
|
-
resolve(this);
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
private _createReject(reject: (error: Error) => void) {
|
|
272
|
-
return (error: Error) => {
|
|
273
|
-
this._rendering = false;
|
|
274
|
-
reject(error);
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Update actual size and key.
|
|
279
|
-
private _computedOptions() {
|
|
280
|
-
const options = this.options();
|
|
281
|
-
const { key = G2_CHART_KEY } = options;
|
|
282
|
-
const { width, height } = sizeOf(options, this._container);
|
|
283
|
-
this._width = width;
|
|
284
|
-
this._height = height;
|
|
285
|
-
this._key = key;
|
|
286
|
-
return { key: this._key, ...options, width, height };
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// Create canvas if it does not exist.
|
|
290
|
-
// DragAndDropPlugin is for interaction.
|
|
291
|
-
// It is OK to register more than one time, G will handle this.
|
|
292
|
-
private _createCanvas() {
|
|
293
|
-
const { width, height } = sizeOf(this.options(), this._container);
|
|
294
|
-
this._plugins.push(new DragAndDropPlugin());
|
|
295
|
-
this._plugins.forEach((d) => this._renderer.registerPlugin(d));
|
|
296
|
-
this._context.canvas = new GCanvas({
|
|
297
|
-
container: this._container,
|
|
298
|
-
width,
|
|
299
|
-
height,
|
|
300
|
-
renderer: this._renderer,
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
private _addToTrailing(): Promise<Chart> {
|
|
305
|
-
// Resolve previous promise, and give up this task.
|
|
306
|
-
this._trailingResolve?.(this);
|
|
307
|
-
|
|
308
|
-
// Create new task.
|
|
309
|
-
this._trailing = true;
|
|
310
|
-
const promise = new Promise<Chart>((resolve, reject) => {
|
|
311
|
-
this._trailingResolve = resolve;
|
|
312
|
-
this._trailingReject = reject;
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
return promise;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
private _onResize = debounce(() => {
|
|
319
|
-
this.forceFit();
|
|
320
|
-
}, 300);
|
|
321
|
-
|
|
322
|
-
private _bindAutoFit() {
|
|
323
|
-
const options = this.options();
|
|
324
|
-
const { autoFit } = options;
|
|
325
|
-
|
|
326
|
-
if (this._hasBindAutoFit) {
|
|
327
|
-
// If it was bind before, unbind it now.
|
|
328
|
-
if (!autoFit) this._unbindAutoFit();
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (autoFit) {
|
|
333
|
-
this._hasBindAutoFit = true;
|
|
334
|
-
window.addEventListener('resize', this._onResize);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
private _unbindAutoFit() {
|
|
339
|
-
if (this._hasBindAutoFit) {
|
|
340
|
-
this._hasBindAutoFit = false;
|
|
341
|
-
window.removeEventListener('resize', this._onResize);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
8
|
+
export const Chart = extend(Runtime, library);
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
2
|
import { DisplayObject } from '@antv/g';
|
|
3
|
-
import { Scale, G2Theme, G2ViewDescriptor } from '
|
|
4
|
-
import { hide, show } from '
|
|
5
|
-
import {
|
|
3
|
+
import { Scale, G2Theme, G2ViewDescriptor } from '../runtime';
|
|
4
|
+
import { hide, show } from '../utils/style';
|
|
5
|
+
import { Composition as Spec } from '../spec';
|
|
6
|
+
import { Node } from './node';
|
|
7
|
+
import { defineProps } from './define';
|
|
8
|
+
import { compositionProps } from './props';
|
|
9
|
+
import { PropsOf } from './types';
|
|
6
10
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
export interface CompositionNode<T = any>
|
|
12
|
+
extends PropsOf<
|
|
13
|
+
typeof compositionProps,
|
|
14
|
+
any, // todo Remove this when update types of Spec.
|
|
15
|
+
CompositionNode & T
|
|
16
|
+
> {}
|
|
17
|
+
|
|
18
|
+
@defineProps(compositionProps)
|
|
19
|
+
export class CompositionNode extends Node<Spec & { [key: string]: any }> {
|
|
12
20
|
protected _key: string;
|
|
13
21
|
|
|
14
22
|
/**
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { isStrictObject } from '../utils/helper';
|
|
2
|
+
import { Node } from './node';
|
|
3
|
+
|
|
4
|
+
export type NodePropertyDescriptor = {
|
|
5
|
+
type: 'object' | 'value' | 'array' | 'node' | 'container' | 'mix';
|
|
6
|
+
key?: string;
|
|
7
|
+
ctor?: new (...args: any[]) => any;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type NodeClass = new (props: any, type?: string) => Node;
|
|
11
|
+
|
|
12
|
+
function defineValueProp(
|
|
13
|
+
Node: NodeClass,
|
|
14
|
+
name: string,
|
|
15
|
+
{ key = name }: NodePropertyDescriptor,
|
|
16
|
+
) {
|
|
17
|
+
Node.prototype[name] = function (value) {
|
|
18
|
+
if (arguments.length === 0) return this.attr(key);
|
|
19
|
+
return this.attr(key, value);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function defineArrayProp(
|
|
24
|
+
Node: NodeClass,
|
|
25
|
+
name: string,
|
|
26
|
+
{ key = name }: NodePropertyDescriptor,
|
|
27
|
+
) {
|
|
28
|
+
Node.prototype[name] = function (value) {
|
|
29
|
+
if (arguments.length === 0) return this.attr(key);
|
|
30
|
+
if (Array.isArray(value)) return this.attr(key, value);
|
|
31
|
+
const array = [...(this.attr(key) || []), value];
|
|
32
|
+
return this.attr(key, array);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function defineObjectProp(
|
|
37
|
+
Node: NodeClass,
|
|
38
|
+
name: string,
|
|
39
|
+
{ key: k = name }: NodePropertyDescriptor,
|
|
40
|
+
) {
|
|
41
|
+
Node.prototype[name] = function (key, value) {
|
|
42
|
+
if (arguments.length === 0) return this.attr(k);
|
|
43
|
+
if (arguments.length === 1 && typeof key !== 'string') {
|
|
44
|
+
return this.attr(k, key);
|
|
45
|
+
}
|
|
46
|
+
const obj = this.attr(k) || {};
|
|
47
|
+
obj[key] = arguments.length === 1 ? true : value;
|
|
48
|
+
return this.attr(k, obj);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function defineMixProp(
|
|
53
|
+
Node: NodeClass,
|
|
54
|
+
name: string,
|
|
55
|
+
descriptor: NodePropertyDescriptor,
|
|
56
|
+
) {
|
|
57
|
+
Node.prototype[name] = function (key) {
|
|
58
|
+
if (arguments.length === 0) return this.attr(name);
|
|
59
|
+
if (Array.isArray(key)) return this.attr(name, { items: key });
|
|
60
|
+
if (
|
|
61
|
+
isStrictObject(key) &&
|
|
62
|
+
(key.title !== undefined || key.items !== undefined)
|
|
63
|
+
) {
|
|
64
|
+
return this.attr(name, key);
|
|
65
|
+
}
|
|
66
|
+
if (key === null || key === false) return this.attr(name, key);
|
|
67
|
+
const obj = this.attr(name) || {};
|
|
68
|
+
const { items = [] } = obj;
|
|
69
|
+
items.push(key);
|
|
70
|
+
obj.items = items;
|
|
71
|
+
return this.attr(name, obj);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function defineNodeProp(
|
|
76
|
+
Node: NodeClass,
|
|
77
|
+
name: string,
|
|
78
|
+
{ ctor }: NodePropertyDescriptor,
|
|
79
|
+
) {
|
|
80
|
+
Node.prototype[name] = function (hocMark?) {
|
|
81
|
+
const node = this.append(ctor);
|
|
82
|
+
if (name === 'mark') {
|
|
83
|
+
node.type = hocMark;
|
|
84
|
+
}
|
|
85
|
+
return node;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function defineContainerProp(
|
|
90
|
+
Node: NodeClass,
|
|
91
|
+
name: string,
|
|
92
|
+
{ ctor }: NodePropertyDescriptor,
|
|
93
|
+
) {
|
|
94
|
+
Node.prototype[name] = function () {
|
|
95
|
+
this.type = null;
|
|
96
|
+
return this.append(ctor);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A decorator to define different type of attribute setter or
|
|
102
|
+
* getter for current node.
|
|
103
|
+
*/
|
|
104
|
+
export function defineProps(
|
|
105
|
+
descriptors: Record<string, NodePropertyDescriptor>,
|
|
106
|
+
) {
|
|
107
|
+
return (Node: NodeClass) => {
|
|
108
|
+
for (const [name, descriptor] of Object.entries(descriptors)) {
|
|
109
|
+
const { type } = descriptor;
|
|
110
|
+
if (type === 'value') defineValueProp(Node, name, descriptor);
|
|
111
|
+
else if (type === 'array') defineArrayProp(Node, name, descriptor);
|
|
112
|
+
else if (type === 'object') defineObjectProp(Node, name, descriptor);
|
|
113
|
+
else if (type === 'node') defineNodeProp(Node, name, descriptor);
|
|
114
|
+
else if (type === 'container')
|
|
115
|
+
defineContainerProp(Node, name, descriptor);
|
|
116
|
+
else if (type === 'mix') defineMixProp(Node, name, descriptor);
|
|
117
|
+
}
|
|
118
|
+
return Node as any;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function nodeProps(
|
|
123
|
+
node: Record<string, new (...args: any[]) => any>,
|
|
124
|
+
): Record<string, NodePropertyDescriptor> {
|
|
125
|
+
return Object.fromEntries(
|
|
126
|
+
Object.entries(node).map(([name, ctor]) => [name, { type: 'node', ctor }]),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { G2Spec } from '../spec';
|
|
2
|
+
import { G2Library } from '../runtime';
|
|
3
|
+
import { Runtime, RuntimeOptions } from './runtime';
|
|
4
|
+
import { MarkOf, CompositionOf as Of } from './types';
|
|
5
|
+
import { MarkNode } from './mark';
|
|
6
|
+
import { CompositionNode } from './composition';
|
|
7
|
+
|
|
8
|
+
type CompositionOf<Library> = Of<
|
|
9
|
+
Library,
|
|
10
|
+
(
|
|
11
|
+
composite?,
|
|
12
|
+
) => CompositionNode<
|
|
13
|
+
CompositionOf<Library> & MarkOf<Library, (composite?) => MarkNode>
|
|
14
|
+
> &
|
|
15
|
+
MarkOf<Library, (composite?) => MarkNode> &
|
|
16
|
+
CompositionOf<Library>
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export type API<Spec, Library> = Runtime<Spec> &
|
|
20
|
+
MarkOf<Library, (composite?) => MarkNode> &
|
|
21
|
+
CompositionOf<Library>;
|
|
22
|
+
|
|
23
|
+
export function extend<
|
|
24
|
+
Spec extends G2Spec = G2Spec,
|
|
25
|
+
Library extends G2Library = G2Library,
|
|
26
|
+
>(
|
|
27
|
+
Runtime: new (options: RuntimeOptions) => Runtime<Spec>,
|
|
28
|
+
library: Library,
|
|
29
|
+
): new (options?: RuntimeOptions) => API<Spec, Library> {
|
|
30
|
+
class Chart extends Runtime {
|
|
31
|
+
constructor(options: Omit<RuntimeOptions, 'lib'>) {
|
|
32
|
+
super({ ...options, lib: library });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return Chart as any;
|
|
36
|
+
}
|
package/src/api/index.ts
CHANGED
package/src/api/library.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stdlib } from '../lib/std';
|
|
2
2
|
import { G2ComponentNamespaces, G2Component } from '../runtime';
|
|
3
3
|
|
|
4
|
-
export const library =
|
|
4
|
+
export const library = stdlib();
|
|
5
5
|
|
|
6
6
|
// @todo Warn if override existing key.
|
|
7
7
|
export function register(
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { G2MarkState, Scale } from '../runtime';
|
|
3
|
+
import { Mark as Spec } from '../spec';
|
|
4
|
+
import { Node } from './node';
|
|
5
|
+
import { defineProps } from './define';
|
|
6
|
+
import { markProps } from './props';
|
|
7
|
+
import { PropsOf } from './types';
|
|
4
8
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
> extends Node<Value, ParentValue, ChildValue> {
|
|
9
|
+
export interface MarkNode extends PropsOf<typeof markProps, Spec, MarkNode> {}
|
|
10
|
+
|
|
11
|
+
@defineProps(markProps)
|
|
12
|
+
export class MarkNode extends Node<Spec & { [key: string]: any }> {
|
|
10
13
|
changeData(data: any) {
|
|
11
14
|
const chart = this.getRoot();
|
|
12
15
|
if (!chart) return;
|
package/src/api/node.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Runtime } from './runtime';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* BFS nodes and execute callback.
|
|
@@ -140,12 +140,12 @@ export class Node<
|
|
|
140
140
|
return this;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
getRoot():
|
|
143
|
+
getRoot(): Runtime {
|
|
144
144
|
// Find the root chart and render.
|
|
145
145
|
let root: Node = this;
|
|
146
146
|
while (root && root.parentNode) {
|
|
147
147
|
root = root.parentNode;
|
|
148
148
|
}
|
|
149
|
-
return root as
|
|
149
|
+
return root as Runtime;
|
|
150
150
|
}
|
|
151
151
|
}
|