Skip to content

Commit

Permalink
perf(smooth): smooth line do not capture event (#3230)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc authored Jan 22, 2021
1 parent 69540f6 commit 71b0a2e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"lint-md-cli": "^0.1.2",
"lint-staged": "^10.2.2",
"lodash": "^4.17.15",
"mock-variable": "^0.0.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"react-i18next": "^11.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/geometry/shape/line/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ each(['line', 'dot', 'dash', 'smooth'], (shapeType) => {
type: 'path',
attrs,
name: 'line',
capture: !smooth,
});

return shape;
Expand Down
45 changes: 45 additions & 0 deletions tests/performance/component/tooltip/pick-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* tooltip hover 的时候拾取性能性能很差,在 2000 条数据的时候,就已经卡的不行了。
*/
import MV from 'mock-variable';
import { Chart } from '../../../../src';
import { createDiv } from '../../../util/dom';

const DATA = MV.arrayOf(MV.shape({
value: MV.number(100, 110),
name: MV.string(8),
}), 20000).mock();

describe('benchmark of tooltip', () => {

it('pick', () => {
const chart = new Chart({
container: createDiv(),
width: 800,
height: 400,
});

chart.scale('value', {
min: 0,
max: 120,
});

chart.data(DATA);
chart
.line()
.position('name*value')
.style({
lineWidth: 3,
})
.shape('type', ['smooth']);

chart.tooltip({
shared: true,
});

chart.render();

// 不知道怎么写断言,只能手动 hover 到线上面,看卡不卡
chart.destroy();
});
});

0 comments on commit 71b0a2e

Please sign in to comment.