antvis / antvis/G2

[Bug]: 高亮交互里获取到的元素不准

Open
#7,293 1 comment 0 reactions 0 assignees View on GitHub
waiting for maintainer
Dominant language
TypeScript
Stars
12.6k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug / 问题描述

目前的高亮返回的元素是以框选坐标往左侧查询元素,即使是要框选一个元素,也会把左侧的元素也算进去,感觉以X轴两个元素的中间点作为分界应该更合理吧

### Reproduction link / 复现链接

_No response_

### Steps to Reproduce the Bug or Issue / 重现步骤

官网的折线图添加下边的事件监听,获取到的数据不准
```
chart.on('brush:end',(param)=>{
alert(param.data.selection[0]);
console.log(param.data.selection)
})
```
比如下边这个示例,要框选1996年,实际上获取到的是1995年和1996年

Image

### Version / 版本

🆕 5.x

### OS / 操作系统

- [ ] macOS
- [x] Windows
- [ ] Linux
- [ ] Others / 其他

### Browser / 浏览器

- [x] Chrome
- [ ] Edge
- [ ] Firefox
- [ ] Safari (Limited support / 有限支持)
- [ ] IE (Nonsupport / 不支持)
- [ ] Others / 其他

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the official line-chart example with the chart.on('brush:end') listener and inspect how brush selection boundaries determine param.data.selection. Trace the interaction code responsible for X-axis element selection and add regression coverage for selecting 1996. Done means selecting 1996 returns only 1996, not 1995 and 1996.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.