@antv/g2 5.0.0-alpha.1 → 5.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g2-lite.min.js +10 -0
- package/dist/g2.min.js +3 -3
- package/esm/adjust/index.d.ts +2 -1
- package/esm/adjust/index.js.map +1 -1
- package/esm/animation/index.d.ts +14 -7
- package/esm/animation/index.js.map +1 -1
- package/esm/animation/scaleInX.js +3 -0
- package/esm/animation/scaleInX.js.map +1 -1
- package/esm/animation/scaleInY.js +3 -0
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/api/chart.d.ts +4 -0
- package/esm/api/chart.js +20 -3
- package/esm/api/chart.js.map +1 -1
- package/esm/api/mark/index.d.ts +3 -3
- package/esm/api/mark/index.js +2 -2
- package/esm/api/mark/index.js.map +1 -1
- package/esm/api/mark/mark.d.ts +4 -4
- package/esm/api/mark/mark.js +6 -5
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -0
- package/esm/api/node.d.ts +4 -5
- package/esm/api/node.js +5 -7
- package/esm/api/node.js.map +1 -1
- package/esm/api/props.d.ts +1 -0
- package/esm/api/props.js +10 -10
- package/esm/api/props.js.map +1 -1
- package/esm/component/axis.d.ts +1 -1
- package/esm/component/axis.js +11 -4
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +10 -5
- package/esm/component/index.js.map +1 -1
- package/esm/composition/index.d.ts +16 -8
- package/esm/composition/index.js.map +1 -1
- package/esm/composition/rect.js +1 -1
- package/esm/composition/rect.js.map +1 -1
- package/esm/coordinate/index.d.ts +24 -12
- package/esm/coordinate/index.js.map +1 -1
- package/esm/data/arc.d.ts +7 -0
- package/esm/data/arc.js +10 -18
- package/esm/data/arc.js.map +1 -1
- package/esm/data/cluster.d.ts +8 -0
- package/esm/data/cluster.js +36 -46
- package/esm/data/cluster.js.map +1 -1
- package/esm/data/custom.d.ts +7 -0
- package/esm/data/custom.js +10 -0
- package/esm/data/custom.js.map +1 -0
- package/esm/data/fetch.js +7 -6
- package/esm/data/fetch.js.map +1 -1
- package/esm/data/filterBy.js +6 -2
- package/esm/data/filterBy.js.map +1 -1
- package/esm/data/index.d.ts +28 -9
- package/esm/data/index.js +6 -1
- package/esm/data/index.js.map +1 -1
- package/esm/data/map.d.ts +7 -0
- package/esm/data/map.js +10 -0
- package/esm/data/map.js.map +1 -0
- package/esm/data/sankey.d.ts +8 -0
- package/esm/data/sankey.js +76 -95
- package/esm/data/sankey.js.map +1 -1
- package/esm/data/sortBy.js +14 -4
- package/esm/data/sortBy.js.map +1 -1
- package/esm/data/tree.d.ts +4 -0
- package/esm/data/tree.js +6 -9
- package/esm/data/tree.js.map +1 -1
- package/esm/data/utils/arc/index.d.ts +1 -1
- package/esm/data/utils/fields.d.ts +6 -0
- package/esm/data/utils/fields.js +15 -0
- package/esm/data/utils/fields.js.map +1 -0
- package/esm/data/voronoi.d.ts +1 -0
- package/esm/data/voronoi.js +1 -22
- package/esm/data/voronoi.js.map +1 -1
- package/esm/data/wordCloud.d.ts +1 -0
- package/esm/data/wordCloud.js +1 -93
- package/esm/data/wordCloud.js.map +1 -1
- package/esm/encode/index.d.ts +8 -4
- package/esm/encode/index.js.map +1 -1
- package/esm/interaction/action/index.d.ts +42 -21
- package/esm/interaction/action/index.js +8 -8
- package/esm/interaction/action/index.js.map +1 -1
- package/esm/interaction/index.d.ts +1 -1
- package/esm/interaction/index.js +0 -1
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/interactor/index.d.ts +4 -2
- package/esm/interaction/interactor/index.js.map +1 -1
- package/esm/mark/annotation/index.d.ts +14 -7
- package/esm/mark/annotation/index.js +6 -6
- package/esm/mark/annotation/index.js.map +1 -1
- package/esm/mark/geometry/{schema.d.ts → box.d.ts} +4 -4
- package/esm/mark/geometry/{schema.js → box.js} +4 -4
- package/esm/mark/geometry/box.js.map +1 -0
- package/esm/mark/geometry/image.js +5 -4
- package/esm/mark/geometry/image.js.map +1 -1
- package/esm/mark/geometry/index.d.ts +22 -13
- package/esm/mark/geometry/index.js +1 -3
- package/esm/mark/geometry/index.js.map +1 -1
- package/esm/mark/geometry/interval.js +0 -1
- package/esm/mark/geometry/interval.js.map +1 -1
- package/esm/mark/geometry/line.js +5 -1
- package/esm/mark/geometry/line.js.map +1 -1
- package/esm/mark/geometry/link.js +1 -1
- package/esm/mark/geometry/link.js.map +1 -1
- package/esm/mark/geometry/point.js +6 -2
- package/esm/mark/geometry/point.js.map +1 -1
- package/esm/mark/geometry/polygon.js +1 -1
- package/esm/mark/geometry/polygon.js.map +1 -1
- package/esm/palette/index.d.ts +4 -2
- package/esm/palette/index.js.map +1 -1
- package/esm/runtime/component.d.ts +1 -1
- package/esm/runtime/component.js +8 -3
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/mark.js +4 -3
- package/esm/runtime/mark.js.map +1 -1
- package/esm/runtime/plot.js +47 -28
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js +15 -6
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/scale.js +1 -1
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/types/component.d.ts +4 -6
- package/esm/runtime/types/options.d.ts +1 -0
- package/esm/scale/index.d.ts +22 -11
- package/esm/scale/index.js.map +1 -1
- package/esm/shape/annotation/text.js +16 -4
- package/esm/shape/annotation/text.js.map +1 -1
- package/esm/shape/{schema → box}/box.d.ts +0 -0
- package/esm/shape/{schema → box}/box.js +2 -2
- package/esm/shape/box/box.js.map +1 -0
- package/esm/shape/index.d.ts +86 -48
- package/esm/shape/index.js +9 -12
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/label/label.js +62 -38
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/{edge → link}/arc.d.ts +0 -0
- package/esm/shape/{edge → link}/arc.js +0 -0
- package/esm/shape/{edge → link}/arc.js.map +1 -1
- package/esm/shape/{edge → link}/smoothEdge.d.ts +0 -0
- package/esm/shape/{edge → link}/smoothEdge.js +0 -0
- package/esm/shape/{edge → link}/smoothEdge.js.map +1 -1
- package/esm/shape/{edge → link}/vhv.d.ts +0 -0
- package/esm/shape/{edge → link}/vhv.js +0 -0
- package/esm/shape/{edge → link}/vhv.js.map +1 -1
- package/esm/shape/{edge → polygon}/ribbon.d.ts +0 -0
- package/esm/shape/{edge → polygon}/ribbon.js +0 -0
- package/esm/shape/polygon/ribbon.js.map +1 -0
- package/esm/spec/data.d.ts +145 -8
- package/esm/spec/geometry.d.ts +5 -3
- package/esm/spec/transform.d.ts +18 -8
- package/esm/spec/transform.js +0 -133
- package/esm/spec/transform.js.map +1 -1
- package/esm/stdlib/index.js +13 -17
- package/esm/stdlib/index.js.map +1 -1
- package/esm/transform/dodgeX.js +7 -3
- package/esm/transform/dodgeX.js.map +1 -1
- package/esm/transform/flexX.d.ts +7 -0
- package/esm/transform/flexX.js +31 -0
- package/esm/transform/flexX.js.map +1 -0
- package/esm/transform/groupX.js +17 -19
- package/esm/transform/groupX.js.map +1 -1
- package/esm/transform/index.d.ts +46 -21
- package/esm/transform/index.js +3 -1
- package/esm/transform/index.js.map +1 -1
- package/esm/transform/normalizeY.js +1 -2
- package/esm/transform/normalizeY.js.map +1 -1
- package/esm/transform/sortX.d.ts +8 -0
- package/esm/transform/sortX.js +60 -0
- package/esm/transform/sortX.js.map +1 -0
- package/esm/transform/stackY.d.ts +1 -1
- package/esm/transform/stackY.js +26 -9
- package/esm/transform/stackY.js.map +1 -1
- package/esm/utils/coordinate.d.ts +1 -0
- package/esm/utils/coordinate.js +3 -0
- package/esm/utils/coordinate.js.map +1 -1
- package/lib/adjust/index.d.ts +2 -1
- package/lib/adjust/index.js.map +1 -1
- package/lib/animation/index.d.ts +14 -7
- package/lib/animation/index.js.map +1 -1
- package/lib/animation/scaleInX.js +3 -0
- package/lib/animation/scaleInX.js.map +1 -1
- package/lib/animation/scaleInY.js +3 -0
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/api/chart.d.ts +4 -0
- package/lib/api/chart.js +20 -3
- package/lib/api/chart.js.map +1 -1
- package/lib/api/mark/index.d.ts +3 -3
- package/lib/api/mark/index.js +1 -1
- package/lib/api/mark/index.js.map +1 -1
- package/lib/api/mark/mark.d.ts +4 -4
- package/lib/api/mark/mark.js +7 -6
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -0
- package/lib/api/node.d.ts +4 -5
- package/lib/api/node.js +5 -7
- package/lib/api/node.js.map +1 -1
- package/lib/api/props.d.ts +1 -0
- package/lib/api/props.js +10 -10
- package/lib/api/props.js.map +1 -1
- package/lib/component/axis.d.ts +1 -1
- package/lib/component/axis.js +11 -4
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +10 -5
- package/lib/component/index.js.map +1 -1
- package/lib/composition/index.d.ts +16 -8
- package/lib/composition/index.js.map +1 -1
- package/lib/composition/rect.js +1 -1
- package/lib/composition/rect.js.map +1 -1
- package/lib/coordinate/index.d.ts +24 -12
- package/lib/coordinate/index.js.map +1 -1
- package/lib/data/arc.d.ts +7 -0
- package/lib/data/arc.js +14 -18
- package/lib/data/arc.js.map +1 -1
- package/lib/data/cluster.d.ts +8 -0
- package/lib/data/cluster.js +41 -46
- package/lib/data/cluster.js.map +1 -1
- package/lib/data/custom.d.ts +7 -0
- package/lib/data/custom.js +14 -0
- package/lib/data/custom.js.map +1 -0
- package/lib/data/fetch.js +6 -5
- package/lib/data/fetch.js.map +1 -1
- package/lib/data/filterBy.js +6 -2
- package/lib/data/filterBy.js.map +1 -1
- package/lib/data/index.d.ts +28 -9
- package/lib/data/index.js +13 -3
- package/lib/data/index.js.map +1 -1
- package/lib/data/map.d.ts +7 -0
- package/lib/data/map.js +14 -0
- package/lib/data/map.js.map +1 -0
- package/lib/data/sankey.d.ts +8 -0
- package/lib/data/sankey.js +80 -95
- package/lib/data/sankey.js.map +1 -1
- package/lib/data/sortBy.js +14 -4
- package/lib/data/sortBy.js.map +1 -1
- package/lib/data/tree.d.ts +4 -0
- package/lib/data/tree.js +10 -9
- package/lib/data/tree.js.map +1 -1
- package/lib/data/utils/arc/index.d.ts +1 -1
- package/lib/data/utils/fields.d.ts +6 -0
- package/lib/data/utils/fields.js +19 -0
- package/lib/data/utils/fields.js.map +1 -0
- package/lib/data/voronoi.d.ts +1 -0
- package/lib/data/voronoi.js +2 -22
- package/lib/data/voronoi.js.map +1 -1
- package/lib/data/wordCloud.d.ts +1 -0
- package/lib/data/wordCloud.js +2 -93
- package/lib/data/wordCloud.js.map +1 -1
- package/lib/encode/index.d.ts +8 -4
- package/lib/encode/index.js.map +1 -1
- package/lib/interaction/action/index.d.ts +42 -21
- package/lib/interaction/action/index.js.map +1 -1
- package/lib/interaction/index.d.ts +1 -1
- package/lib/interaction/index.js +0 -15
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/interactor/index.d.ts +4 -2
- package/lib/interaction/interactor/index.js.map +1 -1
- package/lib/mark/annotation/index.d.ts +14 -7
- package/lib/mark/annotation/index.js.map +1 -1
- package/lib/mark/geometry/{schema.d.ts → box.d.ts} +4 -4
- package/lib/mark/geometry/{schema.js → box.js} +6 -6
- package/lib/mark/geometry/box.js.map +1 -0
- package/lib/mark/geometry/image.js +5 -4
- package/lib/mark/geometry/image.js.map +1 -1
- package/lib/mark/geometry/index.d.ts +22 -13
- package/lib/mark/geometry/index.js +3 -7
- package/lib/mark/geometry/index.js.map +1 -1
- package/lib/mark/geometry/interval.js +0 -1
- package/lib/mark/geometry/interval.js.map +1 -1
- package/lib/mark/geometry/line.js +5 -1
- package/lib/mark/geometry/line.js.map +1 -1
- package/lib/mark/geometry/link.js +1 -1
- package/lib/mark/geometry/link.js.map +1 -1
- package/lib/mark/geometry/point.js +6 -2
- package/lib/mark/geometry/point.js.map +1 -1
- package/lib/mark/geometry/polygon.js +1 -1
- package/lib/mark/geometry/polygon.js.map +1 -1
- package/lib/palette/index.d.ts +4 -2
- package/lib/palette/index.js.map +1 -1
- package/lib/runtime/component.d.ts +1 -1
- package/lib/runtime/component.js +8 -3
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/mark.js +4 -3
- package/lib/runtime/mark.js.map +1 -1
- package/lib/runtime/plot.js +47 -28
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +15 -6
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/scale.js +1 -1
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/types/component.d.ts +4 -6
- package/lib/runtime/types/options.d.ts +1 -0
- package/lib/scale/index.d.ts +22 -11
- package/lib/scale/index.js.map +1 -1
- package/lib/shape/annotation/text.js +16 -4
- package/lib/shape/annotation/text.js.map +1 -1
- package/lib/shape/{schema → box}/box.d.ts +0 -0
- package/lib/shape/{schema → box}/box.js +2 -2
- package/lib/shape/box/box.js.map +1 -0
- package/lib/shape/index.d.ts +86 -48
- package/lib/shape/index.js +10 -16
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/label/label.js +61 -37
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/{edge → link}/arc.d.ts +0 -0
- package/lib/shape/{edge → link}/arc.js +0 -0
- package/lib/shape/{edge → link}/arc.js.map +1 -1
- package/lib/shape/{edge → link}/smoothEdge.d.ts +0 -0
- package/lib/shape/{edge → link}/smoothEdge.js +0 -0
- package/lib/shape/{edge → link}/smoothEdge.js.map +1 -1
- package/lib/shape/{edge → link}/vhv.d.ts +0 -0
- package/lib/shape/{edge → link}/vhv.js +0 -0
- package/lib/shape/{edge → link}/vhv.js.map +1 -1
- package/lib/shape/{edge → polygon}/ribbon.d.ts +0 -0
- package/lib/shape/{edge → polygon}/ribbon.js +0 -0
- package/lib/shape/polygon/ribbon.js.map +1 -0
- package/lib/spec/data.d.ts +145 -8
- package/lib/spec/geometry.d.ts +5 -3
- package/lib/spec/transform.d.ts +18 -8
- package/lib/spec/transform.js +0 -133
- package/lib/spec/transform.js.map +1 -1
- package/lib/stdlib/index.js +9 -13
- package/lib/stdlib/index.js.map +1 -1
- package/lib/transform/dodgeX.js +7 -3
- package/lib/transform/dodgeX.js.map +1 -1
- package/lib/transform/flexX.d.ts +7 -0
- package/lib/transform/flexX.js +35 -0
- package/lib/transform/flexX.js.map +1 -0
- package/lib/transform/groupX.js +16 -18
- package/lib/transform/groupX.js.map +1 -1
- package/lib/transform/index.d.ts +46 -21
- package/lib/transform/index.js +5 -1
- package/lib/transform/index.js.map +1 -1
- package/lib/transform/normalizeY.js +0 -1
- package/lib/transform/normalizeY.js.map +1 -1
- package/lib/transform/sortX.d.ts +8 -0
- package/lib/transform/sortX.js +64 -0
- package/lib/transform/sortX.js.map +1 -0
- package/lib/transform/stackY.d.ts +1 -1
- package/lib/transform/stackY.js +26 -9
- package/lib/transform/stackY.js.map +1 -1
- package/lib/utils/coordinate.d.ts +1 -0
- package/lib/utils/coordinate.js +5 -1
- package/lib/utils/coordinate.js.map +1 -1
- package/package.json +19 -4
- package/src/.DS_Store +0 -0
- package/src/adjust/index.ts +2 -1
- package/src/animation/index.ts +15 -7
- package/src/animation/morphing.ts +1 -1
- package/src/animation/scaleInX.ts +3 -0
- package/src/animation/scaleInY.ts +3 -0
- package/src/api/chart.ts +40 -3
- package/src/api/mark/index.ts +3 -3
- package/src/api/mark/mark.ts +6 -5
- package/src/api/mark/types.ts +1 -0
- package/src/api/node.ts +5 -6
- package/src/api/props.ts +14 -10
- package/src/component/axis.ts +13 -5
- package/src/component/index.ts +11 -5
- package/src/composition/index.ts +17 -8
- package/src/composition/rect.ts +1 -1
- package/src/coordinate/index.ts +25 -12
- package/src/data/arc.ts +13 -18
- package/src/data/cluster.ts +53 -56
- package/src/data/custom.ts +15 -0
- package/src/data/fetch.ts +12 -7
- package/src/data/filterBy.ts +11 -2
- package/src/data/index.ts +29 -9
- package/src/data/map.ts +15 -0
- package/src/data/sankey.ts +92 -95
- package/src/data/sortBy.ts +18 -8
- package/src/data/tree.ts +9 -9
- package/src/data/utils/arc/index.ts +1 -1
- package/src/data/utils/fields.ts +17 -0
- package/src/data/voronoi.ts +2 -0
- package/src/data/wordCloud.ts +2 -0
- package/src/encode/index.ts +9 -4
- package/src/interaction/action/index.ts +43 -45
- package/src/interaction/index.ts +17 -1
- package/src/interaction/interactor/index.ts +5 -2
- package/src/interaction/types.ts +1 -1
- package/src/mark/annotation/index.ts +15 -25
- package/src/mark/geometry/{schema.ts → box.ts} +5 -5
- package/src/mark/geometry/image.ts +4 -3
- package/src/mark/geometry/index.ts +23 -13
- package/src/mark/geometry/interval.ts +0 -1
- package/src/mark/geometry/line.ts +6 -1
- package/src/mark/geometry/link.ts +1 -1
- package/src/mark/geometry/point.ts +5 -2
- package/src/mark/geometry/polygon.ts +1 -1
- package/src/palette/index.ts +5 -2
- package/src/runtime/component.ts +10 -3
- package/src/runtime/mark.ts +4 -3
- package/src/runtime/plot.ts +66 -41
- package/src/runtime/render.ts +16 -10
- package/src/runtime/scale.ts +1 -1
- package/src/runtime/types/component.ts +1 -10
- package/src/runtime/types/options.ts +1 -0
- package/src/scale/index.ts +23 -11
- package/src/shape/annotation/text.ts +16 -4
- package/src/shape/{schema → box}/box.ts +2 -2
- package/src/shape/index.ts +92 -60
- package/src/shape/label/label.ts +81 -47
- package/src/shape/{edge → link}/arc.ts +0 -0
- package/src/shape/{edge → link}/smoothEdge.ts +0 -0
- package/src/shape/{edge → link}/vhv.ts +0 -0
- package/src/shape/{edge → polygon}/ribbon.ts +0 -0
- package/src/spec/data.ts +157 -8
- package/src/spec/geometry.ts +5 -3
- package/src/spec/transform.ts +37 -154
- package/src/stdlib/index.ts +18 -20
- package/src/transform/dodgeX.ts +5 -4
- package/src/transform/flexX.ts +38 -0
- package/src/transform/groupX.ts +25 -8
- package/src/transform/index.ts +47 -24
- package/src/transform/normalizeY.ts +0 -1
- package/src/transform/sortX.ts +48 -0
- package/src/transform/stackY.ts +34 -9
- package/src/utils/coordinate.ts +4 -0
- package/esm/data/connector.d.ts +0 -7
- package/esm/data/connector.js +0 -9
- package/esm/data/connector.js.map +0 -1
- package/esm/mark/geometry/edge.d.ts +0 -13
- package/esm/mark/geometry/edge.js +0 -31
- package/esm/mark/geometry/edge.js.map +0 -1
- package/esm/mark/geometry/node.d.ts +0 -8
- package/esm/mark/geometry/node.js +0 -27
- package/esm/mark/geometry/node.js.map +0 -1
- package/esm/mark/geometry/schema.js.map +0 -1
- package/esm/renderer/canvas.d.ts +0 -10
- package/esm/renderer/canvas.js +0 -18
- package/esm/renderer/canvas.js.map +0 -1
- package/esm/renderer/index.d.ts +0 -1
- package/esm/renderer/index.js +0 -2
- package/esm/renderer/index.js.map +0 -1
- package/esm/shape/edge/edge.d.ts +0 -6
- package/esm/shape/edge/edge.js +0 -11
- package/esm/shape/edge/edge.js.map +0 -1
- package/esm/shape/edge/ribbon.js.map +0 -1
- package/esm/shape/node/point.d.ts +0 -6
- package/esm/shape/node/point.js +0 -27
- package/esm/shape/node/point.js.map +0 -1
- package/esm/shape/node/polygon.d.ts +0 -3
- package/esm/shape/node/polygon.js +0 -8
- package/esm/shape/node/polygon.js.map +0 -1
- package/esm/shape/schema/box.js.map +0 -1
- package/lib/data/connector.d.ts +0 -7
- package/lib/data/connector.js +0 -13
- package/lib/data/connector.js.map +0 -1
- package/lib/mark/geometry/edge.d.ts +0 -13
- package/lib/mark/geometry/edge.js +0 -35
- package/lib/mark/geometry/edge.js.map +0 -1
- package/lib/mark/geometry/node.d.ts +0 -8
- package/lib/mark/geometry/node.js +0 -31
- package/lib/mark/geometry/node.js.map +0 -1
- package/lib/mark/geometry/schema.js.map +0 -1
- package/lib/renderer/canvas.d.ts +0 -10
- package/lib/renderer/canvas.js +0 -22
- package/lib/renderer/canvas.js.map +0 -1
- package/lib/renderer/index.d.ts +0 -1
- package/lib/renderer/index.js +0 -6
- package/lib/renderer/index.js.map +0 -1
- package/lib/shape/edge/edge.d.ts +0 -6
- package/lib/shape/edge/edge.js +0 -15
- package/lib/shape/edge/edge.js.map +0 -1
- package/lib/shape/edge/ribbon.js.map +0 -1
- package/lib/shape/node/point.d.ts +0 -6
- package/lib/shape/node/point.js +0 -31
- package/lib/shape/node/point.js.map +0 -1
- package/lib/shape/node/polygon.d.ts +0 -3
- package/lib/shape/node/polygon.js +0 -12
- package/lib/shape/node/polygon.js.map +0 -1
- package/lib/shape/schema/box.js.map +0 -1
- package/src/data/connector.ts +0 -14
- package/src/mark/geometry/edge.ts +0 -40
- package/src/mark/geometry/node.ts +0 -36
- package/src/renderer/canvas.ts +0 -27
- package/src/renderer/index.ts +0 -1
- package/src/shape/edge/edge.ts +0 -15
- package/src/shape/node/point.ts +0 -32
- package/src/shape/node/polygon.ts +0 -12
package/src/api/chart.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RendererPlugin, Canvas as GCanvas } from '@antv/g';
|
|
2
|
+
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
3
|
+
import { Plugin as DragAndDropPlugin } from '@antv/g-plugin-dragndrop';
|
|
2
4
|
import { G2Context, render } from '../runtime';
|
|
3
5
|
import { ViewComposition } from '../spec';
|
|
4
6
|
import { Node } from './node';
|
|
@@ -40,13 +42,31 @@ function normalizeRoot(node: Node) {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
function valueOf(node: Node): Record<string, any> {
|
|
43
|
-
const value = clone(node.value);
|
|
44
45
|
return {
|
|
45
|
-
...value,
|
|
46
|
+
...node.value,
|
|
46
47
|
type: node.type,
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
function Canvas(
|
|
52
|
+
container: HTMLElement,
|
|
53
|
+
width: number,
|
|
54
|
+
height: number,
|
|
55
|
+
renderer = new CanvasRenderer(),
|
|
56
|
+
plugins = [],
|
|
57
|
+
) {
|
|
58
|
+
// DragAndDropPlugin is for interaction.
|
|
59
|
+
// It is OK to register more than one time, G will handle this.
|
|
60
|
+
plugins.push(new DragAndDropPlugin());
|
|
61
|
+
plugins.forEach((d) => renderer.registerPlugin(d));
|
|
62
|
+
return new GCanvas({
|
|
63
|
+
container,
|
|
64
|
+
width,
|
|
65
|
+
height,
|
|
66
|
+
renderer,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
50
70
|
export function optionsOf(node: Node): Record<string, any> {
|
|
51
71
|
const root = normalizeRoot(node);
|
|
52
72
|
const discovered: Node[] = [root];
|
|
@@ -71,6 +91,8 @@ export type ChartOptions = ViewComposition & {
|
|
|
71
91
|
container?: string | HTMLElement;
|
|
72
92
|
width?: number;
|
|
73
93
|
height?: number;
|
|
94
|
+
renderer?: CanvasRenderer;
|
|
95
|
+
plugins?: RendererPlugin[];
|
|
74
96
|
};
|
|
75
97
|
|
|
76
98
|
type ChartProps = Concrete<ViewComposition>;
|
|
@@ -114,6 +136,21 @@ export class Chart extends Node<ChartOptions> {
|
|
|
114
136
|
|
|
115
137
|
render(): Chart {
|
|
116
138
|
const options = optionsOf(this);
|
|
139
|
+
|
|
140
|
+
// Create canvas and library if it do not exist.
|
|
141
|
+
const { width = 640, height = 480, renderer, plugins } = options;
|
|
142
|
+
const {
|
|
143
|
+
canvas = Canvas(
|
|
144
|
+
document.createElement('div'),
|
|
145
|
+
width,
|
|
146
|
+
height,
|
|
147
|
+
renderer,
|
|
148
|
+
plugins,
|
|
149
|
+
),
|
|
150
|
+
} = this._context;
|
|
151
|
+
|
|
152
|
+
this._context.canvas = canvas;
|
|
153
|
+
|
|
117
154
|
const node = render(options, this._context);
|
|
118
155
|
if (node.parentNode !== this._container) {
|
|
119
156
|
this._container.append(node);
|
package/src/api/mark/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
Polygon,
|
|
10
10
|
Image,
|
|
11
11
|
Text,
|
|
12
|
-
|
|
12
|
+
Box,
|
|
13
13
|
AnnotationText,
|
|
14
14
|
AnnotationLineX,
|
|
15
15
|
AnnotationLineY,
|
|
@@ -30,7 +30,7 @@ export interface Mark {
|
|
|
30
30
|
polygon(): Polygon;
|
|
31
31
|
image(): Image;
|
|
32
32
|
text(): Text;
|
|
33
|
-
|
|
33
|
+
box(): Box;
|
|
34
34
|
annotationText(): AnnotationText;
|
|
35
35
|
annotationLineX(): AnnotationLineX;
|
|
36
36
|
annotationLineY(): AnnotationLineY;
|
|
@@ -51,7 +51,7 @@ export const mark = {
|
|
|
51
51
|
polygon: Polygon,
|
|
52
52
|
image: Image,
|
|
53
53
|
text: Text,
|
|
54
|
-
|
|
54
|
+
box: Box,
|
|
55
55
|
annotationText: AnnotationText,
|
|
56
56
|
annotationLineX: AnnotationLineX,
|
|
57
57
|
annotationLineY: AnnotationLineY,
|
package/src/api/mark/mark.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
PolygonGeometry,
|
|
9
9
|
ImageGeometry,
|
|
10
10
|
TextGeometry,
|
|
11
|
-
|
|
11
|
+
BoxGeometry,
|
|
12
12
|
LineGeometry,
|
|
13
13
|
AnnotationText as AnnotationTextSpec,
|
|
14
14
|
AnnotationLineX as AnnotationLineXSpec,
|
|
@@ -63,8 +63,8 @@ export interface Text extends API<Concrete<TextGeometry>, Text> {
|
|
|
63
63
|
type: 'text';
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export interface
|
|
67
|
-
type: '
|
|
66
|
+
export interface Box extends API<Concrete<BoxGeometry>, Box> {
|
|
67
|
+
type: 'box';
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export interface AnnotationText
|
|
@@ -120,6 +120,7 @@ export const props: NodePropertyDescriptor[] = [
|
|
|
120
120
|
{ name: 'paddingRight', type: 'value' },
|
|
121
121
|
{ name: 'paddingBottom', type: 'value' },
|
|
122
122
|
{ name: 'paddingTop', type: 'value' },
|
|
123
|
+
{ name: 'label', type: 'array', key: 'labels' },
|
|
123
124
|
];
|
|
124
125
|
|
|
125
126
|
@defineProps(props)
|
|
@@ -193,9 +194,9 @@ export class Text extends Node<TextGeometry> {
|
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
@defineProps(props)
|
|
196
|
-
export class
|
|
197
|
+
export class Box extends Node<BoxGeometry> {
|
|
197
198
|
constructor() {
|
|
198
|
-
super({}, '
|
|
199
|
+
super({}, 'box');
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
|
package/src/api/mark/types.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type API<Props extends Geometry, Mark> = {
|
|
|
8
8
|
transform: ArrayAttribute<Props['transform'], Mark>;
|
|
9
9
|
animate: ObjectAttribute<Props['animate'], Mark>;
|
|
10
10
|
key: ValueAttribute<Props['key'], Mark>;
|
|
11
|
+
label: ArrayAttribute<Props['labels'], Mark>;
|
|
11
12
|
class: ValueAttribute<Props['class'], Mark>;
|
|
12
13
|
style: ObjectAttribute<Props['style'], Mark>;
|
|
13
14
|
facet: ValueAttribute<Props['facet'], Mark>;
|
package/src/api/node.ts
CHANGED
|
@@ -29,19 +29,18 @@ export class Node<
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Apply specified transform to current value
|
|
33
|
-
*
|
|
34
|
-
* and then return it.
|
|
32
|
+
* Apply specified transform to current value. Mount the node
|
|
33
|
+
* to replace the original one in the tree and then return it.
|
|
35
34
|
*/
|
|
36
35
|
map(transform = (x: Value): Value => x): this {
|
|
37
|
-
const newValue = transform(
|
|
36
|
+
const newValue = transform(this.value as Value);
|
|
38
37
|
this.value = newValue;
|
|
39
38
|
return this;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* Set or get the specified attribute. It the value is specified, update
|
|
44
|
-
* the attribute of current value and return
|
|
43
|
+
* the attribute of current value and return the node. Otherwise
|
|
45
44
|
* return the the attribute of current value.
|
|
46
45
|
*/
|
|
47
46
|
attr<T extends Value[keyof Value]>(
|
|
@@ -67,7 +66,7 @@ export class Node<
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
|
-
* Apply specified callback to
|
|
69
|
+
* Apply specified callback to the node value.
|
|
71
70
|
*/
|
|
72
71
|
call(
|
|
73
72
|
callback: (node: this, ...params: any[]) => any,
|
package/src/api/props.ts
CHANGED
|
@@ -3,35 +3,39 @@ import { isObject, clone } from '@antv/util';
|
|
|
3
3
|
export type NodePropertyDescriptor = {
|
|
4
4
|
type: 'object' | 'value' | 'array' | 'node' | 'container';
|
|
5
5
|
name: string;
|
|
6
|
+
key?: string;
|
|
6
7
|
ctor?: new (...args: any[]) => any;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
function defineValueProp(Node, { name }: NodePropertyDescriptor) {
|
|
10
|
+
function defineValueProp(Node, { name, key = name }: NodePropertyDescriptor) {
|
|
10
11
|
Node.prototype[name] = function (value) {
|
|
11
|
-
return this.attr(
|
|
12
|
+
return this.attr(key, value);
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
function defineArrayProp(Node, { name }: NodePropertyDescriptor) {
|
|
16
|
+
function defineArrayProp(Node, { name, key = name }: NodePropertyDescriptor) {
|
|
16
17
|
Node.prototype[name] = function (value) {
|
|
17
18
|
if (Array.isArray(value) || value === undefined) {
|
|
18
|
-
return this.attr(
|
|
19
|
+
return this.attr(key, value);
|
|
19
20
|
}
|
|
20
|
-
const array = this.attr(
|
|
21
|
+
const array = this.attr(key);
|
|
21
22
|
const newArray = [...(Array.isArray(array) ? array : [])];
|
|
22
23
|
newArray.push(value);
|
|
23
|
-
return this.attr(
|
|
24
|
+
return this.attr(key, newArray);
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function defineObjectProp(
|
|
28
|
+
function defineObjectProp(
|
|
29
|
+
Node,
|
|
30
|
+
{ name, key: k = name }: NodePropertyDescriptor,
|
|
31
|
+
) {
|
|
28
32
|
Node.prototype[name] = function (key, value) {
|
|
29
33
|
if (isObject(key) || key === undefined) {
|
|
30
|
-
return this.attr(
|
|
34
|
+
return this.attr(k, key);
|
|
31
35
|
}
|
|
32
|
-
const newObject = clone(this.attr(
|
|
36
|
+
const newObject = clone(this.attr(k) || {});
|
|
33
37
|
newObject[key] = value;
|
|
34
|
-
return this.attr(
|
|
38
|
+
return this.attr(k, newObject);
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
|
package/src/component/axis.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Coordinate, Vector2 } from '@antv/coord';
|
|
|
2
2
|
import { Arc, Linear } from '@antv/gui';
|
|
3
3
|
import { Linear as LinearScale } from '@antv/scale';
|
|
4
4
|
import { deepMix } from '@antv/util';
|
|
5
|
+
import { format } from 'd3-format';
|
|
5
6
|
import { isParallel, isPolar, isTranspose } from '../utils/coordinate';
|
|
6
7
|
import {
|
|
7
8
|
BBox,
|
|
@@ -14,7 +15,7 @@ export type AxisOptions = {
|
|
|
14
15
|
position?: GuideComponentPosition;
|
|
15
16
|
zIndex?: number;
|
|
16
17
|
title?: boolean;
|
|
17
|
-
formatter?: (d: any) => string;
|
|
18
|
+
formatter?: (d: any) => string | string;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
function inferPosition(
|
|
@@ -239,6 +240,10 @@ function getGridItems(
|
|
|
239
240
|
});
|
|
240
241
|
}
|
|
241
242
|
|
|
243
|
+
function titleContent(field: string | string[]): string {
|
|
244
|
+
return Array.isArray(field) ? field.join(', ') : field;
|
|
245
|
+
}
|
|
246
|
+
|
|
242
247
|
const ArcAxis = (options) => {
|
|
243
248
|
const { position, formatter = (d) => `${d}` } = options;
|
|
244
249
|
return (scale, value, coordinate, theme) => {
|
|
@@ -330,6 +335,7 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
330
335
|
? {
|
|
331
336
|
tickPadding: labelOffset,
|
|
332
337
|
autoHide: false,
|
|
338
|
+
autoRotate: true,
|
|
333
339
|
style: {},
|
|
334
340
|
}
|
|
335
341
|
: null,
|
|
@@ -351,7 +357,7 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
351
357
|
...(field &&
|
|
352
358
|
title && {
|
|
353
359
|
title: {
|
|
354
|
-
content:
|
|
360
|
+
content: titleContent(field),
|
|
355
361
|
titleAnchor: anchor,
|
|
356
362
|
style: {
|
|
357
363
|
fontWeight: 'bold',
|
|
@@ -376,11 +382,13 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
376
382
|
* @todo Custom style.
|
|
377
383
|
*/
|
|
378
384
|
export const Axis: GCC<AxisOptions> = (options) => {
|
|
379
|
-
const { position } = options;
|
|
385
|
+
const { position, formatter: f = (d) => `${d}` } = options;
|
|
386
|
+
const formatter = typeof f === 'string' ? format(f) : f;
|
|
387
|
+
const normalizedOptions = { ...options, formatter };
|
|
380
388
|
return (scale, value, coordinate, theme) => {
|
|
381
389
|
return position === 'arc'
|
|
382
|
-
? ArcAxis(
|
|
383
|
-
: LinearAxis(
|
|
390
|
+
? ArcAxis(normalizedOptions)(scale, value, coordinate, theme)
|
|
391
|
+
: LinearAxis(normalizedOptions)(scale, value, coordinate, theme);
|
|
384
392
|
};
|
|
385
393
|
};
|
|
386
394
|
|
package/src/component/index.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
export { AxisX
|
|
2
|
-
export { AxisY
|
|
3
|
-
export { LegendCategory
|
|
4
|
-
export { LegendContinuous
|
|
5
|
-
export { TitleComponent
|
|
1
|
+
export { AxisX } from './axisX';
|
|
2
|
+
export { AxisY } from './axisY';
|
|
3
|
+
export { LegendCategory } from './legendCategory';
|
|
4
|
+
export { LegendContinuous } from './legendContinuous';
|
|
5
|
+
export { TitleComponent } from './title';
|
|
6
|
+
|
|
7
|
+
export type { AxisXOptions } from './axisX';
|
|
8
|
+
export type { AxisYOptions } from './axisY';
|
|
9
|
+
export type { LegendCategoryOptions } from './legendCategory';
|
|
10
|
+
export type { LegendContinuousOptions } from './legendContinuous';
|
|
11
|
+
export type { TitleComponentOptions } from './title';
|
package/src/composition/index.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
export { Layer
|
|
2
|
-
export { Flex
|
|
3
|
-
export { View
|
|
4
|
-
export { Mark
|
|
5
|
-
export { Rect
|
|
6
|
-
export { Matrix
|
|
7
|
-
export { Circle
|
|
8
|
-
export { Keyframe
|
|
1
|
+
export { Layer } from './layer';
|
|
2
|
+
export { Flex } from './flex';
|
|
3
|
+
export { View } from './view';
|
|
4
|
+
export { Mark } from './mark';
|
|
5
|
+
export { Rect } from './rect';
|
|
6
|
+
export { Matrix } from './matrix';
|
|
7
|
+
export { Circle } from './circle';
|
|
8
|
+
export { Keyframe } from './keyframe';
|
|
9
|
+
|
|
10
|
+
export type { LayerOptions } from './layer';
|
|
11
|
+
export type { FlexOptions } from './flex';
|
|
12
|
+
export type { ViewOptions } from './view';
|
|
13
|
+
export type { MarkOptions } from './mark';
|
|
14
|
+
export type { RectOptions } from './rect';
|
|
15
|
+
export type { MatrixOptions } from './matrix';
|
|
16
|
+
export type { CircleOptions } from './circle';
|
|
17
|
+
export type { KeyframeOptions } from './keyframe';
|
package/src/composition/rect.ts
CHANGED
|
@@ -130,7 +130,7 @@ export const toGrid = useOverrideAdaptor<G2ViewTree>(() => ({
|
|
|
130
130
|
export const setData = useOverrideAdaptor<G2ViewTree>((options) => {
|
|
131
131
|
const { data } = options;
|
|
132
132
|
const connector = {
|
|
133
|
-
type: '
|
|
133
|
+
type: 'custom',
|
|
134
134
|
callback: () => {
|
|
135
135
|
const { data, encode } = options;
|
|
136
136
|
const { x, y } = encode;
|
package/src/coordinate/index.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
export { Cartesian
|
|
2
|
-
export { Polar
|
|
3
|
-
export { Helix
|
|
4
|
-
export { Transpose
|
|
5
|
-
export { Reflect
|
|
6
|
-
export { ReflectX
|
|
7
|
-
export { ReflectY
|
|
8
|
-
export { Theta
|
|
9
|
-
export { Parallel
|
|
10
|
-
export { Fisheye
|
|
11
|
-
export { FisheyeX
|
|
12
|
-
export { FisheyeY
|
|
1
|
+
export { Cartesian } from './cartesian';
|
|
2
|
+
export { Polar } from './polar';
|
|
3
|
+
export { Helix } from './helix';
|
|
4
|
+
export { Transpose } from './transpose';
|
|
5
|
+
export { Reflect } from './reflect';
|
|
6
|
+
export { ReflectX } from './reflectX';
|
|
7
|
+
export { ReflectY } from './reflectY';
|
|
8
|
+
export { Theta } from './theta';
|
|
9
|
+
export { Parallel } from './parallel';
|
|
10
|
+
export { Fisheye } from './fisheye';
|
|
11
|
+
export { FisheyeX } from './fisheyeX';
|
|
12
|
+
export { FisheyeY } from './fisheyeY';
|
|
13
|
+
|
|
14
|
+
export type { CartesianOptions } from './cartesian';
|
|
15
|
+
export type { PolarOptions } from './polar';
|
|
16
|
+
export type { HelixOptions } from './helix';
|
|
17
|
+
export type { TransposeOptions } from './transpose';
|
|
18
|
+
export type { ReflectOptions } from './reflect';
|
|
19
|
+
export type { ReflectXOptions } from './reflectX';
|
|
20
|
+
export type { ReflectYOptions } from './reflectY';
|
|
21
|
+
export type { ThetaOptions } from './theta';
|
|
22
|
+
export type { ParallelOptions } from './parallel';
|
|
23
|
+
export type { FisheyeOptions } from './fisheye';
|
|
24
|
+
export type { FisheyeXOptions } from './fisheyeX';
|
|
25
|
+
export type { FisheyeYOptions } from './fisheyeY';
|
package/src/data/arc.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// import { Arc as ArcLayout } from '../transform/utils/arc';
|
|
1
|
+
import { DataComponent as DC } from '../runtime';
|
|
2
|
+
import { ArcTransform } from '../spec';
|
|
3
|
+
import { Arc as ArcLayout } from '../data/utils/arc';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export type ArcOptions = Omit<ArcTransform, 'type'>;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// });
|
|
17
|
-
// };
|
|
7
|
+
/**
|
|
8
|
+
* For arc diagram(edge with weight) or chord diagram(with weight)
|
|
9
|
+
*/
|
|
10
|
+
export const Arc: DC<ArcOptions> = (options) => {
|
|
11
|
+
return (data) => {
|
|
12
|
+
return ArcLayout(options)(data);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
// category: 'preprocessor',
|
|
21
|
-
// };
|
|
16
|
+
Arc.props = {};
|
package/src/data/cluster.ts
CHANGED
|
@@ -1,56 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// Cluster.props = {
|
|
55
|
-
// category: 'preprocessor',
|
|
56
|
-
// };
|
|
1
|
+
import { cluster, hierarchy } from 'd3-hierarchy';
|
|
2
|
+
import { DataComponent as DC } from '../runtime';
|
|
3
|
+
import { ClusterTransform } from '../spec';
|
|
4
|
+
|
|
5
|
+
export type ClusterOptions = Omit<ClusterTransform, 'type'>;
|
|
6
|
+
|
|
7
|
+
export const hierarchyFunction = (layoutFunction) => (options) => {
|
|
8
|
+
return (data) => {
|
|
9
|
+
const {
|
|
10
|
+
field = 'value',
|
|
11
|
+
nodeSize,
|
|
12
|
+
separation,
|
|
13
|
+
sortBy,
|
|
14
|
+
as = ['x', 'y'],
|
|
15
|
+
} = options;
|
|
16
|
+
const [x, y] = as;
|
|
17
|
+
|
|
18
|
+
// Process root data.
|
|
19
|
+
const root = hierarchy(data, (d) => d.children)
|
|
20
|
+
.sum((d) => d[field!])
|
|
21
|
+
.sort(sortBy);
|
|
22
|
+
|
|
23
|
+
// Layout
|
|
24
|
+
const c = layoutFunction();
|
|
25
|
+
c.size([1, 1]);
|
|
26
|
+
if (nodeSize) c.nodeSize(nodeSize);
|
|
27
|
+
if (separation) c.separation(separation);
|
|
28
|
+
c(root);
|
|
29
|
+
|
|
30
|
+
const nodes = [];
|
|
31
|
+
root.each((node: any) => {
|
|
32
|
+
node[x] = node.x;
|
|
33
|
+
node[y] = node.y;
|
|
34
|
+
node.name = node.data.name;
|
|
35
|
+
|
|
36
|
+
nodes.push(node);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const edges = root.links();
|
|
40
|
+
edges.forEach((edge) => {
|
|
41
|
+
edge[x] = [edge.source[x], edge.target[x]];
|
|
42
|
+
edge[y] = [edge.source[y], edge.target[y]];
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return { nodes, edges };
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Cluster: DC<ClusterOptions> = (options) => {
|
|
50
|
+
return hierarchyFunction(cluster)(options);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Cluster.props = {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataComponent as DC } from '../runtime';
|
|
2
|
+
import { CustomDataTransform } from '../spec';
|
|
3
|
+
import { identity } from '../utils/helper';
|
|
4
|
+
|
|
5
|
+
export type CustomOptions = Omit<CustomDataTransform, 'type'>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Connector transfom by function.
|
|
9
|
+
*/
|
|
10
|
+
export const Custom: DC<CustomOptions> = (options) => {
|
|
11
|
+
const { callback = identity } = options;
|
|
12
|
+
return (data) => callback(data);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
Custom.props = {};
|
package/src/data/fetch.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import { dsvFormat } from 'd3-dsv';
|
|
2
|
-
import { identity } from '../utils/helper';
|
|
1
|
+
import { dsvFormat, autoType as d3AutoType } from 'd3-dsv';
|
|
3
2
|
import { FetchConnector } from '../spec';
|
|
4
3
|
import { DataComponent as DC } from '../runtime';
|
|
4
|
+
import { identity } from '../utils/helper';
|
|
5
5
|
|
|
6
6
|
export type FetchOptions = Omit<FetchConnector, 'type'>;
|
|
7
7
|
|
|
8
8
|
export const Fetch: DC<FetchOptions> = (options) => {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
value,
|
|
11
|
+
format = value.split('.').pop(),
|
|
12
|
+
delimiter = ',',
|
|
13
|
+
autoType = true,
|
|
14
|
+
} = options;
|
|
10
15
|
return async () => {
|
|
11
16
|
const response = await fetch(value);
|
|
12
17
|
if (format === 'csv') {
|
|
13
18
|
// @see: https://github.com/d3/d3-dsv#dsv_parse
|
|
14
19
|
const str = await response.text();
|
|
15
|
-
return dsvFormat(delimiter).parse(str,
|
|
20
|
+
return dsvFormat(delimiter).parse(str, autoType ? d3AutoType : identity);
|
|
21
|
+
} else if (format === 'json') {
|
|
22
|
+
return await response.json();
|
|
16
23
|
}
|
|
17
|
-
|
|
18
|
-
// @Todo: Remove the `callback`.
|
|
19
|
-
return Array.isArray(data) ? data.map(callback) : data;
|
|
24
|
+
throw new Error(`Unknown format: ${format}.`);
|
|
20
25
|
};
|
|
21
26
|
};
|
|
22
27
|
|
package/src/data/filterBy.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataComponent as DC } from '../runtime';
|
|
2
2
|
import { FilterByTransform } from '../spec';
|
|
3
|
+
import { normalizeFields } from './utils/fields';
|
|
3
4
|
|
|
4
5
|
export type FilterByOptions = Omit<FilterByTransform, 'type'>;
|
|
5
6
|
|
|
@@ -12,8 +13,16 @@ function defined(d: any): boolean {
|
|
|
12
13
|
* It saves datum with every fields defined by default.
|
|
13
14
|
*/
|
|
14
15
|
export const FilterBy: DC<FilterByOptions> = (options) => {
|
|
15
|
-
const { fields: F = []
|
|
16
|
-
|
|
16
|
+
const { fields: F = [] } = options;
|
|
17
|
+
|
|
18
|
+
const normalizedF = normalizeFields(F, defined);
|
|
19
|
+
|
|
20
|
+
return (data) =>
|
|
21
|
+
data.filter((d: any) => {
|
|
22
|
+
return normalizedF.every(([field, callback = defined]) =>
|
|
23
|
+
callback(d[field]),
|
|
24
|
+
);
|
|
25
|
+
});
|
|
17
26
|
};
|
|
18
27
|
|
|
19
28
|
FilterBy.props = {};
|
package/src/data/index.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
export { Fetch
|
|
2
|
-
export { Fold
|
|
3
|
-
export { FilterBy
|
|
4
|
-
export { Pick
|
|
5
|
-
export { Rename
|
|
6
|
-
export { Subset
|
|
7
|
-
export { SortBy
|
|
8
|
-
export { Inline
|
|
9
|
-
export {
|
|
1
|
+
export { Fetch } from './fetch';
|
|
2
|
+
export { Fold } from './fold';
|
|
3
|
+
export { FilterBy } from './filterBy';
|
|
4
|
+
export { Pick } from './pick';
|
|
5
|
+
export { Rename } from './rename';
|
|
6
|
+
export { Subset } from './subset';
|
|
7
|
+
export { SortBy } from './sortBy';
|
|
8
|
+
export { Inline } from './inline';
|
|
9
|
+
export { Custom } from './custom';
|
|
10
|
+
export { Map } from './map';
|
|
11
|
+
export { Cluster } from './cluster';
|
|
12
|
+
export { Tree } from './tree';
|
|
13
|
+
export { Sankey } from './sankey';
|
|
14
|
+
export { Arc } from './arc';
|
|
15
|
+
|
|
16
|
+
export type { FetchOptions } from './fetch';
|
|
17
|
+
export type { FoldOptions } from './fold';
|
|
18
|
+
export type { FilterByOptions } from './filterBy';
|
|
19
|
+
export type { PickOptions } from './pick';
|
|
20
|
+
export type { RenameOptions } from './rename';
|
|
21
|
+
export type { SubsetOptions } from './subset';
|
|
22
|
+
export type { SortByOptions } from './sortBy';
|
|
23
|
+
export type { InlineOptions } from './inline';
|
|
24
|
+
export type { CustomOptions } from './custom';
|
|
25
|
+
export type { MapOptions } from './map';
|
|
26
|
+
export type { ClusterOptions } from './cluster';
|
|
27
|
+
export type { TreeOptions } from './tree';
|
|
28
|
+
export type { SankeyOptions } from './sankey';
|
|
29
|
+
export type { ArcOptions } from './arc';
|