antvis / G2Plot

:dango: An interactive and responsive charting library based on G2.
https://g2plot.antv.antgroup.com
MIT License
2.56k stars 607 forks source link

🐛 [BUG] 如果brush宽度过大,会导致线段重叠 #3717

Open SAKURA-CAT opened 11 months ago

SAKURA-CAT commented 11 months ago

🐛 Bug description [Please make everyone to understand it]

以此情况作为brush的空间:

image

brush结果如下,部分线段被重叠了:

image

但是如果选取空间较小还是正常的,效果如下:

image image

Please provide a link by forking these links G2Plot or GitHub repo, a minimal reproduction.

📷 Step to reproduce

配置图表的代码如下:

;(async function () {
  const data = await getTag(props.sources[0])
  chart = new Line(g2.value, {
    data,
    padding: 'auto',
    xField: 'step',
    yField: 'data',
    // 坐标轴相关
    xAxis: {
      // type: 'timeCat',
      tickCount: 5 // 设置坐标轴刻度数量,防止数据过多导致刻度过密
    },
    yAxis: {},
    // 大小相关
    height: 200,
    autoFit: true,
    // 开启一些交互
    interactions: [{ type: 'brush-x' }],
    // 样式相关
    // smooth: true, // 平滑曲线
    color: experimentColor.value
  })

  chart.render()
})()

data的数据结构类似:

[
{
step:1,
data: 1
},
....
]

🏞 Expected result

我希望线段不要被重叠