@antv/g2 5.0.0-beta.10 → 5.0.0-beta.12
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 +4 -4
- package/esm/api/chart.d.ts +2 -1
- package/esm/api/chart.js +2 -2
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition/base.d.ts +1 -1
- package/esm/api/composition/base.js +6 -17
- package/esm/api/composition/base.js.map +1 -1
- package/esm/api/composition/facetCircle.d.ts +2 -2
- package/esm/api/composition/facetCircle.js +2 -2
- package/esm/api/composition/facetCircle.js.map +1 -1
- package/esm/api/composition/facetRect.d.ts +2 -2
- package/esm/api/composition/facetRect.js +2 -2
- package/esm/api/composition/facetRect.js.map +1 -1
- package/esm/api/composition/geoPath.d.ts +2 -2
- package/esm/api/composition/geoPath.js +2 -2
- package/esm/api/composition/geoPath.js.map +1 -1
- package/esm/api/composition/geoView.d.ts +2 -2
- package/esm/api/composition/geoView.js +2 -2
- package/esm/api/composition/geoView.js.map +1 -1
- package/esm/api/composition/index.d.ts +2 -2
- package/esm/api/composition/index.js +2 -2
- package/esm/api/composition/index.js.map +1 -1
- package/esm/api/composition/repeatMatrix.d.ts +2 -2
- package/esm/api/composition/repeatMatrix.js +2 -2
- package/esm/api/composition/repeatMatrix.js.map +1 -1
- package/esm/api/composition/spaceFlex.d.ts +2 -2
- package/esm/api/composition/spaceFlex.js +2 -2
- package/esm/api/composition/spaceFlex.js.map +1 -1
- package/esm/api/composition/spaceLayer.d.ts +2 -2
- package/esm/api/composition/spaceLayer.js +2 -2
- package/esm/api/composition/spaceLayer.js.map +1 -1
- package/esm/api/composition/timingKeyframe.d.ts +2 -2
- package/esm/api/composition/timingKeyframe.js +2 -2
- package/esm/api/composition/timingKeyframe.js.map +1 -1
- package/esm/api/composition/view.d.ts +2 -2
- package/esm/api/composition/view.js +2 -2
- package/esm/api/composition/view.js.map +1 -1
- 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/mark/base.d.ts +1 -1
- package/esm/api/mark/base.js +7 -7
- package/esm/api/mark/base.js.map +1 -1
- package/esm/api/mark/index.d.ts +1 -0
- package/esm/api/mark/index.js +1 -0
- package/esm/api/mark/index.js.map +1 -1
- package/esm/api/mark/mark.d.ts +27 -27
- package/esm/api/mark/mark.js +28 -27
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -0
- package/esm/api/node.d.ts +1 -1
- package/esm/api/node.js +1 -1
- package/esm/api/node.js.map +1 -1
- package/esm/api/props.d.ts +1 -1
- package/esm/api/props.js +20 -0
- package/esm/api/props.js.map +1 -1
- package/esm/composition/timingKeyframe.js +13 -7
- package/esm/composition/timingKeyframe.js.map +1 -1
- package/esm/composition/view.js +2 -6
- package/esm/composition/view.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/interaction/builtin/tooltip.d.ts +10 -2
- package/esm/interaction/index.d.ts +1 -0
- package/esm/interaction/index.js +1 -0
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/event.d.ts +1 -0
- package/esm/interaction/native/event.js +42 -0
- package/esm/interaction/native/event.js.map +1 -0
- package/esm/interaction/native/tooltip.d.ts +2 -3
- package/esm/interaction/native/tooltip.js +78 -76
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/mark/area.js +1 -0
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/box.js +1 -0
- package/esm/mark/box.js.map +1 -1
- package/esm/mark/boxplot.js +1 -3
- package/esm/mark/boxplot.js.map +1 -1
- package/esm/mark/cell.js +1 -0
- package/esm/mark/cell.js.map +1 -1
- package/esm/mark/connector.js +1 -0
- package/esm/mark/connector.js.map +1 -1
- package/esm/mark/forceGraph.js +1 -1
- package/esm/mark/forceGraph.js.map +1 -1
- package/esm/mark/image.js +1 -0
- package/esm/mark/image.js.map +1 -1
- package/esm/mark/interval.js +1 -0
- package/esm/mark/interval.js.map +1 -1
- package/esm/mark/line.js +1 -0
- package/esm/mark/line.js.map +1 -1
- package/esm/mark/lineX.js +1 -0
- package/esm/mark/lineX.js.map +1 -1
- package/esm/mark/lineY.js +1 -0
- package/esm/mark/lineY.js.map +1 -1
- package/esm/mark/link.js +1 -0
- package/esm/mark/link.js.map +1 -1
- package/esm/mark/pack.js +1 -1
- package/esm/mark/pack.js.map +1 -1
- package/esm/mark/path.js +1 -0
- package/esm/mark/path.js.map +1 -1
- package/esm/mark/point.js +1 -0
- package/esm/mark/point.js.map +1 -1
- package/esm/mark/polygon.js +1 -0
- package/esm/mark/polygon.js.map +1 -1
- package/esm/mark/range.js +1 -0
- package/esm/mark/range.js.map +1 -1
- package/esm/mark/rangeX.js +1 -0
- package/esm/mark/rangeX.js.map +1 -1
- package/esm/mark/rangeY.js +1 -0
- package/esm/mark/rangeY.js.map +1 -1
- package/esm/mark/rect.js +1 -0
- package/esm/mark/rect.js.map +1 -1
- package/esm/mark/sankey.js +1 -1
- package/esm/mark/sankey.js.map +1 -1
- package/esm/mark/shape.js +1 -0
- package/esm/mark/shape.js.map +1 -1
- package/esm/mark/text.js +1 -0
- package/esm/mark/text.js.map +1 -1
- package/esm/mark/tree.js +1 -1
- package/esm/mark/tree.js.map +1 -1
- package/esm/mark/treemap.js +1 -1
- package/esm/mark/treemap.js.map +1 -1
- package/esm/mark/utils.js +1 -5
- package/esm/mark/utils.js.map +1 -1
- package/esm/mark/vector.js +1 -0
- package/esm/mark/vector.js.map +1 -1
- package/esm/mark/wordCloud.js +1 -1
- package/esm/mark/wordCloud.js.map +1 -1
- package/esm/runtime/mark.js +12 -7
- package/esm/runtime/mark.js.map +1 -1
- package/esm/runtime/plot.js +81 -39
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/scale.js +2 -0
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.d.ts +5 -0
- package/esm/runtime/transform.js +63 -6
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +1 -0
- package/esm/runtime/types/component.d.ts +2 -1
- package/esm/runtime/types/mark.d.ts +3 -3
- package/esm/runtime/types/options.d.ts +8 -1
- package/esm/scale/constant.d.ts +4 -0
- package/esm/scale/constant.js +6 -0
- package/esm/scale/constant.js.map +1 -0
- package/esm/scale/index.d.ts +2 -0
- package/esm/scale/index.js +1 -0
- package/esm/scale/index.js.map +1 -1
- package/esm/shape/interval/color.js +6 -4
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/spec/geometry.d.ts +33 -17
- package/esm/spec/interaction.d.ts +6 -1
- package/esm/spec/scale.d.ts +4 -3
- package/esm/stdlib/index.js +3 -3
- package/esm/stdlib/index.js.map +1 -1
- package/esm/transform/groupN.js +2 -2
- package/esm/transform/groupN.js.map +1 -1
- package/esm/transform/maybeTitle.js +13 -3
- package/esm/transform/maybeTitle.js.map +1 -1
- package/esm/transform/maybeTooltip.js +20 -20
- package/esm/transform/maybeTooltip.js.map +1 -1
- package/esm/transform/maybeZeroX.js +2 -2
- package/esm/transform/maybeZeroX.js.map +1 -1
- package/esm/transform/maybeZeroY.js +2 -2
- package/esm/transform/maybeZeroY.js.map +1 -1
- package/esm/transform/maybeZeroY1.js +2 -2
- package/esm/transform/maybeZeroY1.js.map +1 -1
- package/esm/transform/utils/helper.d.ts +12 -0
- package/esm/transform/utils/helper.js +8 -0
- package/esm/transform/utils/helper.js.map +1 -1
- package/esm/utils/helper.js +4 -1
- package/esm/utils/helper.js.map +1 -1
- package/lib/api/chart.d.ts +2 -1
- package/lib/api/chart.js +2 -2
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition/base.d.ts +1 -1
- package/lib/api/composition/base.js +8 -18
- package/lib/api/composition/base.js.map +1 -1
- package/lib/api/composition/facetCircle.d.ts +2 -2
- package/lib/api/composition/facetCircle.js +1 -1
- package/lib/api/composition/facetCircle.js.map +1 -1
- package/lib/api/composition/facetRect.d.ts +2 -2
- package/lib/api/composition/facetRect.js +1 -1
- package/lib/api/composition/facetRect.js.map +1 -1
- package/lib/api/composition/geoPath.d.ts +2 -2
- package/lib/api/composition/geoPath.js +1 -1
- package/lib/api/composition/geoPath.js.map +1 -1
- package/lib/api/composition/geoView.d.ts +2 -2
- package/lib/api/composition/geoView.js +1 -1
- package/lib/api/composition/geoView.js.map +1 -1
- package/lib/api/composition/index.d.ts +2 -2
- package/lib/api/composition/index.js +2 -2
- package/lib/api/composition/index.js.map +1 -1
- package/lib/api/composition/repeatMatrix.d.ts +2 -2
- package/lib/api/composition/repeatMatrix.js +1 -1
- package/lib/api/composition/repeatMatrix.js.map +1 -1
- package/lib/api/composition/spaceFlex.d.ts +2 -2
- package/lib/api/composition/spaceFlex.js +1 -1
- package/lib/api/composition/spaceFlex.js.map +1 -1
- package/lib/api/composition/spaceLayer.d.ts +2 -2
- package/lib/api/composition/spaceLayer.js +1 -1
- package/lib/api/composition/spaceLayer.js.map +1 -1
- package/lib/api/composition/timingKeyframe.d.ts +2 -2
- package/lib/api/composition/timingKeyframe.js +1 -1
- package/lib/api/composition/timingKeyframe.js.map +1 -1
- package/lib/api/composition/view.d.ts +2 -2
- package/lib/api/composition/view.js +1 -1
- package/lib/api/composition/view.js.map +1 -1
- 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/mark/base.d.ts +1 -1
- package/lib/api/mark/base.js +9 -9
- package/lib/api/mark/base.js.map +1 -1
- package/lib/api/mark/index.d.ts +1 -0
- package/lib/api/mark/index.js +3 -1
- package/lib/api/mark/index.js.map +1 -1
- package/lib/api/mark/mark.d.ts +27 -27
- package/lib/api/mark/mark.js +27 -26
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -0
- package/lib/api/node.d.ts +1 -1
- package/lib/api/node.js +1 -1
- package/lib/api/node.js.map +1 -1
- package/lib/api/props.d.ts +1 -1
- package/lib/api/props.js +20 -0
- package/lib/api/props.js.map +1 -1
- package/lib/composition/timingKeyframe.js +13 -7
- package/lib/composition/timingKeyframe.js.map +1 -1
- package/lib/composition/view.js +2 -6
- package/lib/composition/view.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/builtin/tooltip.d.ts +10 -2
- package/lib/interaction/index.d.ts +1 -0
- package/lib/interaction/index.js +3 -1
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/event.d.ts +1 -0
- package/lib/interaction/native/event.js +46 -0
- package/lib/interaction/native/event.js.map +1 -0
- package/lib/interaction/native/tooltip.d.ts +2 -3
- package/lib/interaction/native/tooltip.js +76 -74
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/mark/area.js +1 -0
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/box.js +1 -0
- package/lib/mark/box.js.map +1 -1
- package/lib/mark/boxplot.js +1 -3
- package/lib/mark/boxplot.js.map +1 -1
- package/lib/mark/cell.js +1 -0
- package/lib/mark/cell.js.map +1 -1
- package/lib/mark/connector.js +1 -0
- package/lib/mark/connector.js.map +1 -1
- package/lib/mark/forceGraph.js +1 -1
- package/lib/mark/forceGraph.js.map +1 -1
- package/lib/mark/image.js +1 -0
- package/lib/mark/image.js.map +1 -1
- package/lib/mark/interval.js +1 -0
- package/lib/mark/interval.js.map +1 -1
- package/lib/mark/line.js +1 -0
- package/lib/mark/line.js.map +1 -1
- package/lib/mark/lineX.js +1 -0
- package/lib/mark/lineX.js.map +1 -1
- package/lib/mark/lineY.js +1 -0
- package/lib/mark/lineY.js.map +1 -1
- package/lib/mark/link.js +1 -0
- package/lib/mark/link.js.map +1 -1
- package/lib/mark/pack.js +1 -1
- package/lib/mark/pack.js.map +1 -1
- package/lib/mark/path.js +1 -0
- package/lib/mark/path.js.map +1 -1
- package/lib/mark/point.js +1 -0
- package/lib/mark/point.js.map +1 -1
- package/lib/mark/polygon.js +1 -0
- package/lib/mark/polygon.js.map +1 -1
- package/lib/mark/range.js +1 -0
- package/lib/mark/range.js.map +1 -1
- package/lib/mark/rangeX.js +1 -0
- package/lib/mark/rangeX.js.map +1 -1
- package/lib/mark/rangeY.js +1 -0
- package/lib/mark/rangeY.js.map +1 -1
- package/lib/mark/rect.js +1 -0
- package/lib/mark/rect.js.map +1 -1
- package/lib/mark/sankey.js +1 -1
- package/lib/mark/sankey.js.map +1 -1
- package/lib/mark/shape.js +1 -0
- package/lib/mark/shape.js.map +1 -1
- package/lib/mark/text.js +1 -0
- package/lib/mark/text.js.map +1 -1
- package/lib/mark/tree.js +1 -1
- package/lib/mark/tree.js.map +1 -1
- package/lib/mark/treemap.js +1 -1
- package/lib/mark/treemap.js.map +1 -1
- package/lib/mark/utils.js +1 -5
- package/lib/mark/utils.js.map +1 -1
- package/lib/mark/vector.js +1 -0
- package/lib/mark/vector.js.map +1 -1
- package/lib/mark/wordCloud.js +1 -1
- package/lib/mark/wordCloud.js.map +1 -1
- package/lib/runtime/mark.js +11 -6
- package/lib/runtime/mark.js.map +1 -1
- package/lib/runtime/plot.js +81 -39
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/scale.js +2 -0
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.d.ts +5 -0
- package/lib/runtime/transform.js +65 -6
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +1 -0
- package/lib/runtime/types/component.d.ts +2 -1
- package/lib/runtime/types/mark.d.ts +3 -3
- package/lib/runtime/types/options.d.ts +8 -1
- package/lib/scale/constant.d.ts +4 -0
- package/lib/scale/constant.js +10 -0
- package/lib/scale/constant.js.map +1 -0
- package/lib/scale/index.d.ts +2 -0
- package/lib/scale/index.js +3 -1
- package/lib/scale/index.js.map +1 -1
- package/lib/shape/interval/color.js +6 -4
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/spec/geometry.d.ts +33 -17
- package/lib/spec/interaction.d.ts +6 -1
- package/lib/spec/scale.d.ts +4 -3
- package/lib/stdlib/index.js +1 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/transform/groupN.js +1 -1
- package/lib/transform/groupN.js.map +1 -1
- package/lib/transform/maybeTitle.js +12 -2
- package/lib/transform/maybeTitle.js.map +1 -1
- package/lib/transform/maybeTooltip.js +20 -20
- package/lib/transform/maybeTooltip.js.map +1 -1
- package/lib/transform/maybeZeroX.js +1 -1
- package/lib/transform/maybeZeroX.js.map +1 -1
- package/lib/transform/maybeZeroY.js +1 -1
- package/lib/transform/maybeZeroY.js.map +1 -1
- package/lib/transform/maybeZeroY1.js +1 -1
- package/lib/transform/maybeZeroY1.js.map +1 -1
- package/lib/transform/utils/helper.d.ts +12 -0
- package/lib/transform/utils/helper.js +11 -1
- package/lib/transform/utils/helper.js.map +1 -1
- package/lib/utils/helper.js +4 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +4 -4
- package/src/api/chart.ts +2 -2
- package/src/api/composition/base.ts +5 -7
- package/src/api/composition/facetCircle.ts +2 -2
- package/src/api/composition/facetRect.ts +2 -2
- package/src/api/composition/geoPath.ts +2 -2
- package/src/api/composition/geoView.ts +2 -2
- package/src/api/composition/index.ts +2 -2
- package/src/api/composition/repeatMatrix.ts +2 -2
- package/src/api/composition/spaceFlex.ts +2 -2
- package/src/api/composition/spaceLayer.ts +2 -2
- package/src/api/composition/timingKeyframe.ts +2 -2
- package/src/api/composition/view.ts +2 -2
- package/src/api/index.ts +2 -0
- package/src/api/mark/base.ts +7 -7
- package/src/api/mark/index.ts +2 -0
- package/src/api/mark/mark.ts +28 -27
- package/src/api/mark/types.ts +1 -0
- package/src/api/node.ts +1 -1
- package/src/api/props.ts +22 -1
- package/src/composition/timingKeyframe.ts +13 -7
- package/src/composition/view.ts +1 -9
- package/src/index.ts +1 -1
- package/src/interaction/index.ts +1 -0
- package/src/interaction/native/event.ts +44 -0
- package/src/interaction/native/tooltip.ts +78 -95
- package/src/mark/area.ts +1 -0
- package/src/mark/box.ts +1 -0
- package/src/mark/boxplot.ts +1 -3
- package/src/mark/cell.ts +1 -0
- package/src/mark/connector.ts +1 -0
- package/src/mark/forceGraph.ts +1 -1
- package/src/mark/image.ts +1 -0
- package/src/mark/interval.ts +1 -0
- package/src/mark/line.ts +1 -0
- package/src/mark/lineX.ts +1 -0
- package/src/mark/lineY.ts +1 -0
- package/src/mark/link.ts +1 -0
- package/src/mark/pack.ts +1 -1
- package/src/mark/path.ts +1 -0
- package/src/mark/point.ts +1 -0
- package/src/mark/polygon.ts +1 -0
- package/src/mark/range.ts +1 -0
- package/src/mark/rangeX.ts +1 -0
- package/src/mark/rangeY.ts +1 -0
- package/src/mark/rect.ts +1 -0
- package/src/mark/sankey.ts +1 -1
- package/src/mark/shape.ts +1 -0
- package/src/mark/text.ts +1 -0
- package/src/mark/tree.ts +1 -1
- package/src/mark/treemap.ts +1 -1
- package/src/mark/utils.ts +1 -5
- package/src/mark/vector.ts +1 -0
- package/src/mark/wordCloud.ts +1 -1
- package/src/runtime/mark.ts +13 -5
- package/src/runtime/plot.ts +117 -50
- package/src/runtime/scale.ts +2 -0
- package/src/runtime/transform.ts +72 -6
- package/src/runtime/types/common.ts +1 -0
- package/src/runtime/types/component.ts +2 -0
- package/src/runtime/types/mark.ts +3 -3
- package/src/runtime/types/options.ts +8 -1
- package/src/scale/constant.ts +11 -0
- package/src/scale/index.ts +2 -0
- package/src/shape/interval/color.ts +11 -7
- package/src/spec/geometry.ts +38 -30
- package/src/spec/interaction.ts +5 -1
- package/src/spec/scale.ts +6 -1
- package/src/stdlib/index.ts +4 -0
- package/src/transform/groupN.ts +2 -2
- package/src/transform/maybeTitle.ts +11 -3
- package/src/transform/maybeTooltip.ts +17 -21
- package/src/transform/maybeZeroX.ts +2 -2
- package/src/transform/maybeZeroY.ts +2 -2
- package/src/transform/maybeZeroY1.ts +2 -2
- package/src/transform/utils/helper.ts +10 -0
- package/src/utils/helper.ts +6 -1
package/src/runtime/plot.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { mapObject } from '../utils/array';
|
|
|
7
7
|
import { CHART_LIFE_CIRCLE } from '../utils/event';
|
|
8
8
|
import {
|
|
9
9
|
appendTransform,
|
|
10
|
-
compose,
|
|
11
10
|
copyAttributes,
|
|
12
11
|
defined,
|
|
13
12
|
error,
|
|
@@ -100,6 +99,12 @@ export async function plot<T extends G2ViewTree>(
|
|
|
100
99
|
);
|
|
101
100
|
const typeOf = (node: G2ViewTree) => {
|
|
102
101
|
const { type } = node;
|
|
102
|
+
if (typeof type === 'function') {
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
const { props = {} } = type;
|
|
105
|
+
const { composite = true } = props;
|
|
106
|
+
if (composite) return 'mark';
|
|
107
|
+
}
|
|
103
108
|
return typeof type === 'string' && marks.has(type) ? 'mark' : type;
|
|
104
109
|
};
|
|
105
110
|
const isMark = (node: G2ViewTree) => typeOf(node) === 'mark';
|
|
@@ -226,7 +231,7 @@ export async function plot<T extends G2ViewTree>(
|
|
|
226
231
|
// Apply interactions.
|
|
227
232
|
for (const option of inferInteraction(options)) {
|
|
228
233
|
const interaction = useInteraction(option);
|
|
229
|
-
const destroy = interaction(target, enterViewInstances);
|
|
234
|
+
const destroy = interaction(target, enterViewInstances, context.emitter);
|
|
230
235
|
nameInteraction.set(option.type, { destroy });
|
|
231
236
|
}
|
|
232
237
|
}
|
|
@@ -243,7 +248,7 @@ export async function plot<T extends G2ViewTree>(
|
|
|
243
248
|
|
|
244
249
|
// Apply new interaction.
|
|
245
250
|
const interaction = useInteraction(option);
|
|
246
|
-
const destroy = interaction(target, updateViewInstances);
|
|
251
|
+
const destroy = interaction(target, updateViewInstances, context.emitter);
|
|
247
252
|
nameInteraction.set(options.type, { destroy });
|
|
248
253
|
}
|
|
249
254
|
}
|
|
@@ -311,11 +316,80 @@ async function initializeView(
|
|
|
311
316
|
options: G2View,
|
|
312
317
|
library: G2Library,
|
|
313
318
|
): Promise<[G2ViewDescriptor, G2ViewTree[]]> {
|
|
314
|
-
const
|
|
319
|
+
const flattenOptions = await transformMarks(options, library);
|
|
320
|
+
|
|
321
|
+
const mergedOptions = bubbleOptions(flattenOptions);
|
|
322
|
+
// @todo Remove this.
|
|
323
|
+
// !!! NOTE: Mute original view options.
|
|
324
|
+
// Update interaction and coordinate for this view.
|
|
325
|
+
options.interaction = mergedOptions.interaction;
|
|
326
|
+
options.coordinate = mergedOptions.coordinate;
|
|
327
|
+
|
|
328
|
+
const transformedOptions = coordinate2Transform(mergedOptions, library);
|
|
315
329
|
const state = await initializeMarks(transformedOptions, library);
|
|
316
330
|
return initializeState(state, transformedOptions, library);
|
|
317
331
|
}
|
|
318
332
|
|
|
333
|
+
function bubbleOptions(options: G2View): G2View {
|
|
334
|
+
const {
|
|
335
|
+
coordinate: viewCoordinate = {},
|
|
336
|
+
interaction: viewInteraction = {},
|
|
337
|
+
marks,
|
|
338
|
+
...rest
|
|
339
|
+
} = options;
|
|
340
|
+
const markCoordinates = marks.map((d) => d.coordinate || {});
|
|
341
|
+
const markInteractions = marks.map((d) => d.interaction || {});
|
|
342
|
+
const newCoordinate = [...markCoordinates, viewCoordinate].reduceRight(
|
|
343
|
+
(prev, cur) => deepMix(prev, cur),
|
|
344
|
+
{},
|
|
345
|
+
);
|
|
346
|
+
const newInteraction = [viewInteraction, ...markInteractions].reduce(
|
|
347
|
+
(prev, cur) => deepMix(prev, cur),
|
|
348
|
+
{},
|
|
349
|
+
);
|
|
350
|
+
return {
|
|
351
|
+
...rest,
|
|
352
|
+
marks,
|
|
353
|
+
coordinate: newCoordinate,
|
|
354
|
+
interaction: newInteraction,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async function transformMarks(
|
|
359
|
+
options: G2View,
|
|
360
|
+
library: G2Library,
|
|
361
|
+
): Promise<G2View> {
|
|
362
|
+
const [useMark, createMark] = useLibrary<G2MarkOptions, MarkComponent, Mark>(
|
|
363
|
+
'mark',
|
|
364
|
+
library,
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
const { marks } = options;
|
|
368
|
+
const flattenMarks = [];
|
|
369
|
+
const discovered = [...marks];
|
|
370
|
+
|
|
371
|
+
// Pre order traversal.
|
|
372
|
+
while (discovered.length) {
|
|
373
|
+
const [node] = discovered.splice(0, 1);
|
|
374
|
+
// Apply data transform to get data.
|
|
375
|
+
const mark = (await applyTransform(node, library)) as G2Mark;
|
|
376
|
+
const { type = error('G2Mark type is required.'), key } = mark;
|
|
377
|
+
const { props = {} } = createMark(type);
|
|
378
|
+
const { composite = true } = props;
|
|
379
|
+
if (!composite) flattenMarks.push(mark);
|
|
380
|
+
else {
|
|
381
|
+
// Convert composite mark to marks.
|
|
382
|
+
const marks = await (
|
|
383
|
+
useMark as (options: G2MarkOptions) => CompositeMark
|
|
384
|
+
)(mark)(options);
|
|
385
|
+
const M = Array.isArray(marks) ? marks : [marks];
|
|
386
|
+
discovered.unshift(...M.map((d, i) => ({ ...d, key: `${key}-${i}` })));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return { ...options, marks: flattenMarks };
|
|
391
|
+
}
|
|
392
|
+
|
|
319
393
|
async function initializeMarks(
|
|
320
394
|
options: G2View,
|
|
321
395
|
library: G2Library,
|
|
@@ -324,7 +398,7 @@ async function initializeMarks(
|
|
|
324
398
|
'theme',
|
|
325
399
|
library,
|
|
326
400
|
);
|
|
327
|
-
const [
|
|
401
|
+
const [, createMark] = useLibrary<G2MarkOptions, MarkComponent, Mark>(
|
|
328
402
|
'mark',
|
|
329
403
|
library,
|
|
330
404
|
);
|
|
@@ -337,31 +411,10 @@ async function initializeMarks(
|
|
|
337
411
|
const theme = useTheme(inferTheme(partialTheme));
|
|
338
412
|
const markState = new Map<G2Mark, G2MarkState>();
|
|
339
413
|
|
|
340
|
-
// Apply data transform to get data.
|
|
341
|
-
const dataMarks = [];
|
|
342
|
-
for (const mark of partialMarks) {
|
|
343
|
-
const dataMark = await applyTransform(mark, library);
|
|
344
|
-
dataMarks.push(dataMark);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Convert composite mark to single mark.
|
|
348
|
-
const flattenMarks = await Promise.all(
|
|
349
|
-
dataMarks.map(async (mark) => {
|
|
350
|
-
const { type = error('G2Mark type is required.'), key } = mark;
|
|
351
|
-
const { props } = createMark(type);
|
|
352
|
-
const { composite = false } = props;
|
|
353
|
-
if (!composite) return mark;
|
|
354
|
-
const marks = await (
|
|
355
|
-
useMark as (options: G2MarkOptions) => CompositeMark
|
|
356
|
-
)(mark)(options);
|
|
357
|
-
return marks.map((d, i) => ({ key: `${key}-${i}`, ...d }));
|
|
358
|
-
}),
|
|
359
|
-
).then((res) => res.flat());
|
|
360
|
-
|
|
361
414
|
// Initialize channels for marks.
|
|
362
|
-
for (const markOptions of
|
|
415
|
+
for (const markOptions of partialMarks) {
|
|
363
416
|
const { type } = markOptions;
|
|
364
|
-
const { props } = createMark(type);
|
|
417
|
+
const { props = {} } = createMark(type);
|
|
365
418
|
const markAndState = await initializeMark(markOptions, props, library);
|
|
366
419
|
if (markAndState) {
|
|
367
420
|
const [initializedMark, state] = markAndState;
|
|
@@ -474,7 +527,7 @@ function initializeState(
|
|
|
474
527
|
modifier,
|
|
475
528
|
key: markKey,
|
|
476
529
|
} = mark;
|
|
477
|
-
const { index, channels } = state;
|
|
530
|
+
const { index, channels, tooltip } = state;
|
|
478
531
|
const scale = Object.fromEntries(
|
|
479
532
|
channels.map(({ name, scale }) => [name, scale]),
|
|
480
533
|
);
|
|
@@ -495,6 +548,8 @@ function initializeState(
|
|
|
495
548
|
);
|
|
496
549
|
const count = dataDomain || I.length;
|
|
497
550
|
const T = modifier ? modifier(P, count, layout) : [];
|
|
551
|
+
const titleOf = (i) => tooltip.title?.[i]?.value;
|
|
552
|
+
const itemsOf = (i) => tooltip.items.map((V) => V[i]);
|
|
498
553
|
const visualData: Record<string, any>[] = I.map((d, i) => {
|
|
499
554
|
const datum = {
|
|
500
555
|
points: P[i],
|
|
@@ -502,12 +557,20 @@ function initializeState(
|
|
|
502
557
|
index: d,
|
|
503
558
|
markKey,
|
|
504
559
|
viewKey: key,
|
|
560
|
+
...(tooltip && {
|
|
561
|
+
title: titleOf(d),
|
|
562
|
+
items: itemsOf(d),
|
|
563
|
+
}),
|
|
505
564
|
};
|
|
506
565
|
for (const [k, V] of Object.entries(value)) {
|
|
507
566
|
datum[k] = V[d];
|
|
508
567
|
if (S) datum[`series${upperFirst(k)}`] = S[i].map((i) => V[i]);
|
|
509
568
|
}
|
|
510
569
|
if (S) datum['seriesIndex'] = S[i];
|
|
570
|
+
if (S && tooltip) {
|
|
571
|
+
datum['seriesItems'] = S[i].map((si) => itemsOf(si));
|
|
572
|
+
datum['seriesTitle'] = S[i].map((si) => titleOf(si));
|
|
573
|
+
}
|
|
511
574
|
return datum;
|
|
512
575
|
});
|
|
513
576
|
state.data = visualData;
|
|
@@ -680,12 +743,14 @@ async function plotView(
|
|
|
680
743
|
// Render marks with corresponding data.
|
|
681
744
|
for (const [mark, state] of markState.entries()) {
|
|
682
745
|
const { data } = state;
|
|
683
|
-
const { key, class: cls } = mark;
|
|
746
|
+
const { key, class: cls, type } = mark;
|
|
684
747
|
const shapeFunction = createMarkShapeFunction(mark, state, view, library);
|
|
685
748
|
const enterFunction = createEnterFunction(mark, state, view, library);
|
|
686
749
|
const updateFunction = createUpdateFunction(mark, state, view, library);
|
|
687
750
|
const exitFunction = createExitFunction(mark, state, view, library);
|
|
688
751
|
const facetElements = selectFacetElements(selection, cls, 'element');
|
|
752
|
+
const classNames = [ELEMENT_CLASS_NAME];
|
|
753
|
+
if (typeof type === 'string') classNames.push(type);
|
|
689
754
|
const T = selection
|
|
690
755
|
.select(`#${key}`)
|
|
691
756
|
.selectAll(className(ELEMENT_CLASS_NAME))
|
|
@@ -699,7 +764,7 @@ async function plotView(
|
|
|
699
764
|
(enter) =>
|
|
700
765
|
enter
|
|
701
766
|
.append(shapeFunction)
|
|
702
|
-
.attr('className',
|
|
767
|
+
.attr('className', classNames.join(' '))
|
|
703
768
|
.transition(function (data) {
|
|
704
769
|
return enterFunction(data, [this]);
|
|
705
770
|
}),
|
|
@@ -995,17 +1060,22 @@ function computeAnimationExtent(markState): [number, number] {
|
|
|
995
1060
|
for (const [mark, state] of markState) {
|
|
996
1061
|
const { animate = {} } = mark;
|
|
997
1062
|
const { data } = state;
|
|
1063
|
+
const { enter = {}, update = {}, exit = {} } = animate;
|
|
1064
|
+
const {
|
|
1065
|
+
type: defaultUpdateType,
|
|
1066
|
+
duration: defaultUpdateDuration = 300,
|
|
1067
|
+
delay: defaultUpdateDelay = 0,
|
|
1068
|
+
} = update;
|
|
998
1069
|
const {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
} = animate;
|
|
1070
|
+
type: defaultEnterType,
|
|
1071
|
+
duration: defaultEnterDuration = 300,
|
|
1072
|
+
delay: defaultEnterDelay = 0,
|
|
1073
|
+
} = enter;
|
|
1074
|
+
const {
|
|
1075
|
+
type: defaultExitType,
|
|
1076
|
+
duration: defaultExitDuration = 300,
|
|
1077
|
+
delay: defaultExitDelay = 0,
|
|
1078
|
+
} = exit;
|
|
1009
1079
|
for (const d of data) {
|
|
1010
1080
|
const {
|
|
1011
1081
|
updateType = defaultUpdateType,
|
|
@@ -1146,7 +1216,7 @@ function createAnimationFunction(
|
|
|
1146
1216
|
shapeName(mark, defaultShape),
|
|
1147
1217
|
).props;
|
|
1148
1218
|
const { [type]: defaultEffectTiming = {} } = theme;
|
|
1149
|
-
const animate =
|
|
1219
|
+
const animate = mark.animate?.[type] || {};
|
|
1150
1220
|
return (data, from, to) => {
|
|
1151
1221
|
const {
|
|
1152
1222
|
[`${type}Type`]: animation,
|
|
@@ -1226,14 +1296,11 @@ function inferTheme(theme: G2ThemeOptions = { type: 'light' }): G2ThemeOptions {
|
|
|
1226
1296
|
* @todo Infer builtin tooltips.
|
|
1227
1297
|
*/
|
|
1228
1298
|
function inferInteraction(view: G2View): G2InteractionOptions[] {
|
|
1229
|
-
const defaults = {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1234
|
-
{},
|
|
1235
|
-
);
|
|
1236
|
-
return Object.entries(all)
|
|
1299
|
+
const defaults = {
|
|
1300
|
+
event: true,
|
|
1301
|
+
};
|
|
1302
|
+
const { interaction = {} } = view;
|
|
1303
|
+
return Object.entries(deepMix(defaults, interaction))
|
|
1237
1304
|
.filter((d) => !!d[1])
|
|
1238
1305
|
.map(([key, value]) => ({
|
|
1239
1306
|
type: key,
|
package/src/runtime/scale.ts
CHANGED
package/src/runtime/transform.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Primitive } from 'd3-array';
|
|
2
2
|
import { deepMix } from '@antv/util';
|
|
3
3
|
import { indexOf, mapObject } from '../utils/array';
|
|
4
|
-
import { composeAsync, defined } from '../utils/helper';
|
|
4
|
+
import { composeAsync, defined, isStrictObject } from '../utils/helper';
|
|
5
5
|
import { useLibrary } from './library';
|
|
6
6
|
import { createColumnOf } from './mark';
|
|
7
7
|
import { Data, DataComponent } from './types/data';
|
|
@@ -77,7 +77,6 @@ export function inferChannelsType(
|
|
|
77
77
|
return [I, { ...mark, encode: typedEncode }];
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// @todo Move visual property to style instead of flagging visual.
|
|
81
80
|
export function maybeVisualChannel(
|
|
82
81
|
I: number[],
|
|
83
82
|
mark: G2Mark,
|
|
@@ -88,7 +87,7 @@ export function maybeVisualChannel(
|
|
|
88
87
|
const newEncode = mapObject(encode, (channel, name) => {
|
|
89
88
|
const { type } = channel;
|
|
90
89
|
if (type !== 'constant' || isPosition(name)) return channel;
|
|
91
|
-
return { ...channel,
|
|
90
|
+
return { ...channel, constant: true };
|
|
92
91
|
});
|
|
93
92
|
return [I, { ...mark, encode: newEncode }];
|
|
94
93
|
}
|
|
@@ -106,6 +105,73 @@ export function extractColumns(
|
|
|
106
105
|
return [I, { ...mark, encode: valuedEncode }];
|
|
107
106
|
}
|
|
108
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Normalize mark.tooltip to {title, items}.
|
|
110
|
+
*/
|
|
111
|
+
export function normalizeTooltip(
|
|
112
|
+
I: number[],
|
|
113
|
+
mark: G2Mark,
|
|
114
|
+
context: TransformContext,
|
|
115
|
+
): [number[], G2Mark] {
|
|
116
|
+
const { tooltip = {} } = mark;
|
|
117
|
+
const isFullTooltip = (tooltip) => {
|
|
118
|
+
if (Object.keys(tooltip).length === 0) return true;
|
|
119
|
+
const { title, items } = tooltip;
|
|
120
|
+
return title !== undefined || items !== undefined;
|
|
121
|
+
};
|
|
122
|
+
if (tooltip === null) return [I, mark];
|
|
123
|
+
if (Array.isArray(tooltip)) {
|
|
124
|
+
return [I, { ...mark, tooltip: { items: tooltip } }];
|
|
125
|
+
}
|
|
126
|
+
if (isStrictObject(tooltip) && isFullTooltip(tooltip)) {
|
|
127
|
+
return [I, { ...mark, tooltip }];
|
|
128
|
+
}
|
|
129
|
+
return [I, { ...mark, tooltip: { items: [tooltip] } }];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function extractTooltip(
|
|
133
|
+
I: number[],
|
|
134
|
+
mark: G2Mark,
|
|
135
|
+
context: TransformContext,
|
|
136
|
+
): [number[], G2Mark] {
|
|
137
|
+
const { data, encode, tooltip = {} } = mark;
|
|
138
|
+
if (tooltip === null) return [I, mark];
|
|
139
|
+
const valueOf = (item) => {
|
|
140
|
+
if (!item) return item;
|
|
141
|
+
if (typeof item === 'string') {
|
|
142
|
+
return I.map((i) => ({ name: item, value: data[i][item] }));
|
|
143
|
+
}
|
|
144
|
+
if (isStrictObject(item)) {
|
|
145
|
+
const { field, channel, color, name = field } = item;
|
|
146
|
+
const channelField = channel && encode[channel].field;
|
|
147
|
+
return I.map((i) => ({
|
|
148
|
+
name: name || channelField || channel,
|
|
149
|
+
color,
|
|
150
|
+
value: field
|
|
151
|
+
? data[i][field]
|
|
152
|
+
: channel
|
|
153
|
+
? encode[channel].value[i]
|
|
154
|
+
: null,
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
if (typeof item === 'function') {
|
|
158
|
+
return I.map((i) => {
|
|
159
|
+
const v = item(data[i], i, data, encode);
|
|
160
|
+
if (isStrictObject(v)) return v;
|
|
161
|
+
return { value: v };
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return item;
|
|
165
|
+
};
|
|
166
|
+
const { title, items = [], ...rest } = tooltip;
|
|
167
|
+
const newTooltip = {
|
|
168
|
+
title: valueOf(title),
|
|
169
|
+
items: items.map(valueOf),
|
|
170
|
+
...rest,
|
|
171
|
+
};
|
|
172
|
+
return [I, { ...mark, tooltip: newTooltip }];
|
|
173
|
+
}
|
|
174
|
+
|
|
109
175
|
export function maybeArrayField(
|
|
110
176
|
I: number[],
|
|
111
177
|
mark: G2Mark,
|
|
@@ -191,9 +257,9 @@ export function maybeNonAnimate(
|
|
|
191
257
|
if (animate || animate === undefined) return [I, mark];
|
|
192
258
|
deepMix(mark, {
|
|
193
259
|
animate: {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
260
|
+
enter: { type: null },
|
|
261
|
+
exit: { type: null },
|
|
262
|
+
update: { type: null },
|
|
197
263
|
},
|
|
198
264
|
});
|
|
199
265
|
return [I, mark];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Coordinate, Transformation } from '@antv/coord';
|
|
2
2
|
import { DisplayObject, IAnimation as GAnimation } from '@antv/g';
|
|
3
|
+
import EventEmitter from '@antv/event-emitter';
|
|
3
4
|
import { G2ViewTree } from './options';
|
|
4
5
|
import {
|
|
5
6
|
G2Theme,
|
|
@@ -191,6 +192,7 @@ export type AnimationComponent<O = Record<string, unknown>> = G2BaseComponent<
|
|
|
191
192
|
export type Interaction = (
|
|
192
193
|
target: G2ViewInstance,
|
|
193
194
|
viewInstances: G2ViewInstance[],
|
|
195
|
+
emitter?: EventEmitter,
|
|
194
196
|
) => void;
|
|
195
197
|
export type InteractionComponent<O = Record<string, unknown>> = G2BaseComponent<
|
|
196
198
|
Interaction,
|
|
@@ -10,13 +10,13 @@ export type MarkOptions = Record<string, any>;
|
|
|
10
10
|
|
|
11
11
|
export type MarkComponent<O extends MarkOptions = MarkOptions> = {
|
|
12
12
|
(options?: O): Mark;
|
|
13
|
-
props
|
|
13
|
+
props?: MarkProps;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export type MarkProps = {
|
|
17
|
-
defaultShape
|
|
17
|
+
defaultShape?: string;
|
|
18
18
|
defaultLabelShape?: string;
|
|
19
|
-
channels
|
|
19
|
+
channels?: Channel[];
|
|
20
20
|
preInference?: TransformSpec[];
|
|
21
21
|
postInference?: TransformSpec[];
|
|
22
22
|
composite?: boolean;
|
|
@@ -83,6 +83,7 @@ export type G2View = {
|
|
|
83
83
|
theme?: G2ThemeOptions;
|
|
84
84
|
title?: G2TitleOptions;
|
|
85
85
|
coordinates?: G2CoordinateOptions[];
|
|
86
|
+
coordinate?: Record<string, any>;
|
|
86
87
|
component?: G2GuideComponentOptions[];
|
|
87
88
|
interaction?: Record<string, any>;
|
|
88
89
|
marks?: G2Mark[];
|
|
@@ -105,12 +106,17 @@ export type G2Mark = {
|
|
|
105
106
|
scale?: Record<string, G2ScaleOptions>;
|
|
106
107
|
encode?: Record<string, any | G2EncodeOptions>;
|
|
107
108
|
type?: string | MarkComponent;
|
|
108
|
-
animate?:
|
|
109
|
+
animate?: {
|
|
110
|
+
enter?: Record<string, Primitive>;
|
|
111
|
+
update?: Record<string, Primitive>;
|
|
112
|
+
exit?: Record<string, Primitive>;
|
|
113
|
+
};
|
|
109
114
|
facet?: boolean;
|
|
110
115
|
axis?: boolean | Record<string, any>;
|
|
111
116
|
legend?: boolean | Record<string, any>;
|
|
112
117
|
slider?: Record<string, any>;
|
|
113
118
|
scrollbar?: Record<string, any>;
|
|
119
|
+
tooltip?: any; // @todo
|
|
114
120
|
filter?: (i: number) => boolean;
|
|
115
121
|
children?: G2MarkChildrenCallback;
|
|
116
122
|
dataDomain?: number;
|
|
@@ -119,6 +125,7 @@ export type G2Mark = {
|
|
|
119
125
|
style?: Record<string, Primitive>;
|
|
120
126
|
labels?: Record<string, any>[];
|
|
121
127
|
interaction?: Record<string, any>;
|
|
128
|
+
coordinate?: Record<string, any>;
|
|
122
129
|
};
|
|
123
130
|
|
|
124
131
|
export type G2MarkChildrenCallback = (
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Constant as ConstantScale } from '@antv/scale';
|
|
2
|
+
import { ConstantScale as ConstantScaleSpec } from '../spec';
|
|
3
|
+
import { ScaleComponent as SC } from '../runtime';
|
|
4
|
+
|
|
5
|
+
export type ConstantOptions = Omit<ConstantScaleSpec, 'type'>;
|
|
6
|
+
|
|
7
|
+
export const Constant: SC<ConstantOptions> = (options) => {
|
|
8
|
+
return new ConstantScale(options);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
Constant.props = {};
|
package/src/scale/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { Quantile } from './quantile';
|
|
|
11
11
|
export { Quantize } from './quantize';
|
|
12
12
|
export { Sqrt } from './sqrt';
|
|
13
13
|
export { Sequential } from './sequential';
|
|
14
|
+
export { Constant } from './constant';
|
|
14
15
|
|
|
15
16
|
export type { BandOptions } from './band';
|
|
16
17
|
export type { LinearOptions } from './linear';
|
|
@@ -25,3 +26,4 @@ export type { QuantileOptions } from './quantile';
|
|
|
25
26
|
export type { QuantizeOptions } from './quantize';
|
|
26
27
|
export type { SqrtOptions } from './sqrt';
|
|
27
28
|
export type { SequentialOptions } from './sequential';
|
|
29
|
+
export type { ConstantOptions } from './constant';
|
|
@@ -147,13 +147,17 @@ export const Color: SC<ColorOptions> = (options) => {
|
|
|
147
147
|
insetTop,
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
return (
|
|
151
|
+
select(rect(points, value, coordinate, extendedStyle))
|
|
152
|
+
.call(applyStyle, defaults)
|
|
153
|
+
.style(colorAttribute, color)
|
|
154
|
+
.style(toOpacityKey(options), opacity)
|
|
155
|
+
.style('lineWidth', lineWidth)
|
|
156
|
+
.style('stroke', stroke === undefined ? color : stroke)
|
|
157
|
+
// shape.style has higher priority.
|
|
158
|
+
.call(applyStyle, rest)
|
|
159
|
+
.node()
|
|
160
|
+
);
|
|
157
161
|
};
|
|
158
162
|
};
|
|
159
163
|
|
package/src/spec/geometry.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarkComponent } from '../runtime';
|
|
1
|
+
import { MarkComponent, Primitive } from '../runtime';
|
|
2
2
|
import { Encode } from './encode';
|
|
3
3
|
import { Transform } from './transform';
|
|
4
4
|
import { Scale } from './scale';
|
|
@@ -93,8 +93,7 @@ export type ChannelTypes =
|
|
|
93
93
|
| 'groupKey'
|
|
94
94
|
| 'label'
|
|
95
95
|
| 'position'
|
|
96
|
-
| 'series'
|
|
97
|
-
| `tooltip${number}`;
|
|
96
|
+
| 'series';
|
|
98
97
|
|
|
99
98
|
export type BaseGeometry<
|
|
100
99
|
T extends GeometryTypes,
|
|
@@ -149,36 +148,13 @@ export type BaseGeometry<
|
|
|
149
148
|
frame?: boolean;
|
|
150
149
|
labels?: Record<string, any>[];
|
|
151
150
|
stack?: boolean;
|
|
151
|
+
tooltip?: Tooltip;
|
|
152
152
|
animate?:
|
|
153
153
|
| boolean
|
|
154
154
|
| {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
enterEasing?: string;
|
|
159
|
-
enterFill?: 'forwards' | 'none' | 'backwards' | 'both' | 'auto';
|
|
160
|
-
updateType?: AnimationTypes;
|
|
161
|
-
updateDuration?: number;
|
|
162
|
-
updateDelay?: number;
|
|
163
|
-
updateEasing?: string;
|
|
164
|
-
updateFill?:
|
|
165
|
-
| 'forwards'
|
|
166
|
-
| 'none'
|
|
167
|
-
| 'backwards'
|
|
168
|
-
| 'forwards'
|
|
169
|
-
| 'both'
|
|
170
|
-
| 'auto';
|
|
171
|
-
exitType?: AnimationTypes;
|
|
172
|
-
exitDuration?: number;
|
|
173
|
-
exitDelay?: number;
|
|
174
|
-
exitEasing?: string;
|
|
175
|
-
exitFill?:
|
|
176
|
-
| 'forwards'
|
|
177
|
-
| 'none'
|
|
178
|
-
| 'backwards'
|
|
179
|
-
| 'forwards'
|
|
180
|
-
| 'both'
|
|
181
|
-
| 'auto';
|
|
155
|
+
enter?: Animation | null | boolean;
|
|
156
|
+
update?: Animation | null | boolean;
|
|
157
|
+
exit?: Animation | null | boolean;
|
|
182
158
|
};
|
|
183
159
|
cartesian?: boolean;
|
|
184
160
|
layout?: Record<string, any>;
|
|
@@ -192,6 +168,14 @@ type StateOptions = {
|
|
|
192
168
|
unselected?: Record<string, any>; // @todo
|
|
193
169
|
};
|
|
194
170
|
|
|
171
|
+
export type Animation = {
|
|
172
|
+
type?: AnimationTypes;
|
|
173
|
+
duration?: number;
|
|
174
|
+
delay?: number;
|
|
175
|
+
easing?: string;
|
|
176
|
+
fill?: 'forwards' | 'none' | 'backwards' | 'both' | 'auto';
|
|
177
|
+
};
|
|
178
|
+
|
|
195
179
|
export type Axis = {
|
|
196
180
|
tickCount?: number;
|
|
197
181
|
labelFormatter?: any;
|
|
@@ -325,3 +309,27 @@ export type WordCloudMark = BaseGeometry<
|
|
|
325
309
|
};
|
|
326
310
|
|
|
327
311
|
export type CustomComponent = BaseGeometry<MarkComponent>;
|
|
312
|
+
|
|
313
|
+
export type Tooltip =
|
|
314
|
+
| TooltipItem
|
|
315
|
+
| TooltipItem[]
|
|
316
|
+
| { title?: Encodeable<TooltipTitle>; items?: TooltipItem[] }
|
|
317
|
+
| null;
|
|
318
|
+
|
|
319
|
+
export type TooltipTitle = string | { field?: string; channel?: string };
|
|
320
|
+
|
|
321
|
+
export type TooltipItem =
|
|
322
|
+
| string
|
|
323
|
+
| { name?: string; color?: string; channel?: string; field?: string }
|
|
324
|
+
| Encodeable<Primitive>
|
|
325
|
+
| Encodeable<TooltipItemValue>;
|
|
326
|
+
|
|
327
|
+
export type TooltipItemValue = {
|
|
328
|
+
name?: string;
|
|
329
|
+
color?: string;
|
|
330
|
+
value?: Primitive;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export type Encodeable<T> =
|
|
334
|
+
| T
|
|
335
|
+
| ((d: any, index: number, data: any[], column: any) => T);
|
package/src/spec/interaction.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionComponent } from '../runtime';
|
|
2
|
-
import { ChannelTypes } from './geometry';
|
|
2
|
+
import { ChannelTypes, TooltipItemValue } from './geometry';
|
|
3
3
|
import { FisheyeCoordinate } from './coordinate';
|
|
4
4
|
|
|
5
5
|
export type Interaction =
|
|
@@ -197,6 +197,10 @@ export type TooltipInteraction = {
|
|
|
197
197
|
crosshairs?: boolean;
|
|
198
198
|
// @todo
|
|
199
199
|
item?: any;
|
|
200
|
+
render?: (
|
|
201
|
+
event, // @todo
|
|
202
|
+
options: { title: 'string'; items: TooltipItemValue[] },
|
|
203
|
+
) => HTMLElement | string;
|
|
200
204
|
};
|
|
201
205
|
|
|
202
206
|
export type FisheyeInteraction = {
|
package/src/spec/scale.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
QuantizeOptions,
|
|
13
13
|
SqrtOptions,
|
|
14
14
|
SequentialOptions,
|
|
15
|
+
ConstantOptions,
|
|
15
16
|
} from '@antv/scale';
|
|
16
17
|
import { ScaleComponent } from '../runtime';
|
|
17
18
|
import { Palette } from './palette';
|
|
@@ -30,7 +31,8 @@ export type Scale =
|
|
|
30
31
|
| QuantizeScale
|
|
31
32
|
| QuantileScale
|
|
32
33
|
| SequentialScale
|
|
33
|
-
| CustomScale
|
|
34
|
+
| CustomScale
|
|
35
|
+
| ConstantScale;
|
|
34
36
|
|
|
35
37
|
export type ScaleTypes =
|
|
36
38
|
| 'linear'
|
|
@@ -46,6 +48,7 @@ export type ScaleTypes =
|
|
|
46
48
|
| 'quantize'
|
|
47
49
|
| 'quantile'
|
|
48
50
|
| 'sequential'
|
|
51
|
+
| 'constant'
|
|
49
52
|
| ScaleComponent;
|
|
50
53
|
|
|
51
54
|
export type BaseScale<T extends ScaleTypes, O> = {
|
|
@@ -88,4 +91,6 @@ export type QuantizeScale = BaseScale<'quantize', QuantizeOptions>;
|
|
|
88
91
|
|
|
89
92
|
export type SequentialScale = BaseScale<'sequential', SequentialOptions>;
|
|
90
93
|
|
|
94
|
+
export type ConstantScale = BaseScale<'constant', ConstantOptions>;
|
|
95
|
+
|
|
91
96
|
export type CustomScale = BaseScale<ScaleComponent, { [key: string]: any }>;
|