Skip to content

Commit

Permalink
feat: chart update (#1739)
Browse files Browse the repository at this point in the history
Co-authored-by: xuying.xu <xuying.xu@alibaba-inc.com>
  • Loading branch information
tangying1027 and xuying.xu committed Mar 1, 2023
1 parent ca29507 commit 839faba
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions packages/f2/src/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ class Chart<

on(eventName: string, listener: (...args: any[]) => void) {
this.gesture = this.gesture ? this.gesture : new Gesture(this.coordRef.current);
this.gesture.on(eventName, (ev) => {
const { x, y } = ev;
isInBBox(this.getCoord(), { x, y }) && listener(ev);
});
this.gesture.on(eventName, listener);
}

off(eventName: string, listener: (...args: any[]) => void) {
Expand Down
5 changes: 3 additions & 2 deletions packages/f2/src/components/geometry/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ class Selection<
}

didMount() {
const { props, state, context } = this;
const { props, state } = this;
const { selection, chart } = props;
if (!selection) return;
// 默认为 click
const { triggerOn = 'click' } = selection;
context.gesture.on(triggerOn, (ev) => {
chart.on(triggerOn, (ev) => {
const { points, canvasX: x, canvasY: y } = ev;
const point = triggerOn === 'click' ? { x, y } : points[0];
const records = this.getSnapRecords(point);
const { type = 'single', cancelable = true } = selection;

if (!records || !records.length) {
if (cancelable) {
this.setState({
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/f2/test/components/tooltip/tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('tooltip', () => {
expect(context).toMatchImageSnapshot();
});

it('Tooltip 超出边界不响应', async () => {
it('Tooltip 超出边界会展示边界值', async () => {
const context = createContext('Tooltip 超出边界会展示边界值');
const onChangeMockCallback = jest.fn();
const { props } = (
Expand Down

0 comments on commit 839faba

Please sign in to comment.