Skip to content

Commit

Permalink
feat(interaction): add elementpointmove interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
wb-xcf804241 committed Mar 14, 2024
1 parent 8aed000 commit a6a9f86
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
4 changes: 3 additions & 1 deletion __tests__/plots/static/flare-element-point-move-pie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function flareElementPointMovePie(): G2Spec {
legendFilter: false,
elementPointMove: {
selection: [2],
style: { pathLineDash: [2, 4], pathStroke: '#fff', pathLineWidth: 2 },
pathLineDash: [2, 4],
pathStroke: '#fff',
pathLineWidth: 2,
},
},
};
Expand Down
16 changes: 7 additions & 9 deletions site/examples/interaction/data/demo/line-element-point-move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ chart
.interaction({
legendFilter: false,
elementPointMove: {
style: {
pointR: 8,
pointStrokeWidth: 2,
pointActiveStroke: '#fff',
pathLineDash: [2, 4],
pathStroke: 'red',
labelFontSize: 14,
labelY: 24,
},
pointR: 8,
pointStrokeWidth: 2,
pointActiveStroke: '#fff',
pathLineDash: [2, 4],
pathStroke: 'red',
labelFontSize: 14,
labelY: 24,
},
})
.encode('x', 'year')
Expand Down
8 changes: 3 additions & 5 deletions site/examples/interaction/data/demo/pie-element-point-move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ chart
.interaction({
legendFilter: false,
elementPointMove: {
style: {
pathLineDash: [2, 4],
pathStroke: '#fff',
pathLineWidth: 2,
},
pathLineDash: [2, 4],
pathStroke: '#fff',
pathLineWidth: 2,
},
})
.encode('y', 'count')
Expand Down
7 changes: 2 additions & 5 deletions src/interaction/elementPointMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import {

export type ElementPointMoveOptions = {
selection?: number[];
labelStyle?: TextStyleProps;
lineDashPathStyle?: PathStyleProps;
pointStyle?: CircleStyleProps;
precision?: number;
[key: string]: any;
};
Expand Down Expand Up @@ -187,9 +184,9 @@ const getSamePointPosition = (center, point, target) => {
export function ElementPointMove(
elementPointMoveOptions: ElementPointMoveOptions = {},
) {
const { selection = [], style = {}, precision = 2 } = elementPointMoveOptions;
const { selection = [], precision = 2, ...style } = elementPointMoveOptions;

const defaultStyle = { ...DEFAULT_STYLE, ...style };
const defaultStyle = { ...DEFAULT_STYLE, ...(style || {}) };

// Shape default style.
const pathDefaultStyle = subObject(defaultStyle, 'path') as PathStyleProps;
Expand Down

0 comments on commit a6a9f86

Please sign in to comment.