Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 G2 图表的单元格显示 tooltip 会抛出 Error #2843

Closed
1 of 5 tasks
duganlx opened this issue Aug 1, 2024 · 3 comments · Fixed by #2864
Closed
1 of 5 tasks

🐛 G2 图表的单元格显示 tooltip 会抛出 Error #2843

duganlx opened this issue Aug 1, 2024 · 3 comments · Fixed by #2864
Assignees
Labels
🐛 bug 这个是一个 bug next 2.0-next 版本的问题 released on @next

Comments

@duganlx
Copy link
Contributor

duganlx commented Aug 1, 2024

🏷 Version

Package Version
@antv/s2 2.0.0-next.25
@antv/s2-react 2.0.0-next.24
@antv/s2-vue
@antv/g2 5.2.2

Sheet Type

  • PivotSheet
  • TableSheet
  • GridAnalysisSheet
  • StrategySheet
  • EditableSheet

🖋 Description

我在明细表中的一个单元格中画了 G2 的图,用鼠标点击该单元时,不出现 tooltip 并且在控制台中会抛出 Error,如下图所示。

image

image

当在 s2Option 中将 tooltip 设置为不显示(tooltip:{enable: false})时,就不会出现在控制台中出现该 Error 信息,所以我判断是 tooltip 显示时的问题。

⌨️ Code Snapshots

s2Options 和 SheetComponent 的配置内容、报错截图如下所示。

s2Options
class CustomDataCell extends DataCell {
  drawTextShape() {
    if (this.isMultiData()) {
      const rcd = this.getRenderChartData();
      if (Array.isArray(rcd)) {
        return drawCustomContent(this);
      }

      return null;
    }

    super.drawTextShape();
  }
}

s2Options= {
  width: 600,
  height: 400,
  seriesNumber: { enable: true, text: "序号" },
  tooltip: {
    enable: true,
  },
  frozen: {
    rowCount: 1,
  },
  style: {
    rowCell: {
      heightByField: {
        "0": 100,
      },
      height: 24,
    },
  },
  dataCell: (viewMeta: any, spreadsheet: any) => {
    return new CustomDataCell(viewMeta, spreadsheet);
  },
};
SheetComponent
<SheetComponent
  sheetType="table"
  dataCfg={s2DataConfig}
  options={s2Options}
  onDataCellRender={(cell) => {
    // 普通数值单元格正常展示
    if (!cell.isChartData()) {
      return;
    }

    // 获取 G2 渲染到 S2 单元格内所需配置
    const chartOptions = cell.getRenderChartOptions();

    renderToMountedElement(chartOptions, {
      // 指定渲染容器为当前单元格
      group: cell,
      // 根据渲染的图表, 自行选择 G2 library: https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib
      library: stdlib(),
    });
  }}
/>
控制台报错信息

控制台一共会出现四个报错信息

image

🔗 Reproduce Link

https://codesandbox.io/p/sandbox/s2-tooltip-bug-vhnv2s

🤔 Steps to Reproduce

  1. 点击 F12 打开 DevTools
  2. 鼠标移动到绘制了G2柱状图的单元格中并点击
  3. 观察控制台中的输出,能看到Error报错信息

😊 Expected Behavior

鼠标点击/鼠标移入 带有G2绘制图的单元格时,在 DevTools 控制台中不出现任何错误信息

😅 Current Behavior

鼠标点击/鼠标移入 带有G2绘制图的单元格时,在 DevTools 控制台中出现错误信息

💻 System information

Environment Info
System window 10
Browser chrome: v127.0.6533.73
@github-actions github-actions bot added the next 2.0-next 版本的问题 label Aug 1, 2024
@lijinke666 lijinke666 self-assigned this Aug 16, 2024
@lijinke666
Copy link
Member

感谢你详细的描述, 这里是没兼容到

明细表普通单元格点击 tooltip 展示的是自身的数值, 对于自身是图表的场景不应该渲染 tooltip, 这里是错误的把图表数据渲染在 Tooltip 的 JSX 中, 所以报错了

image

@lijinke666 lijinke666 added the 🐛 bug 这个是一个 bug label Aug 16, 2024
Copy link
Contributor

你好 @duganlx,很抱歉给你带来了不好的体验, 我们会尽快排查问题并修复, 请关注后续发布日志.

Hello, @duganlx, We are so sorry for the bad experience. We will troubleshoot and fix the problem as soon as possible. Please pay attention to the follow-up change logs.

@lijinke666
Copy link
Member

🎉 This issue has been resolved in version @antv/s2-v2.0.0-next.27 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug 这个是一个 bug next 2.0-next 版本的问题 released on @next
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants