antvis/G2

tooltip render函数items只能拿到color name value #6638

583849487 posted onGitHub

Describe the bug / 问题描述

tooltip render函数items只能拿到color name value,为什么不能拿到chart.data中的数据来自定义tooltip???

No response

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

No response

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他

在对应mark的tooltip里配置自定义的items,然后在interaction里的items里就能拿到:

({
  tooltip: {
    items: [
      (d, index, data, column) => ({
        color: d.sold > 150 ? 'red' : 'blue', // 指定 item 的颜色
        name: index === 0 ? d.genre : `${d.genre} ${data[i].genre}`, // 指定 item 的名字
        value: column.y.value[i], // 使用 y 通道的值
        custom: d.custom, // 在这里配置你的自定义数据
      }),
    ],
  },
});
    interaction: {
      tooltip: {
        render: (e, { items, title }) => {
          return ``;
        },
      },
    },
posted by interstellarmt about 1 month ago

⚠️ This issue has been automatically closed due to inactivity.

  • If the issue is still relevant and important to you, feel free to:
    1. Reopen with additional information
    2. Create a new issue with updated context
    3. Reference any related issues or discussions

We close inactive issues to keep our backlog manageable and focused on active issues.

Your contribution makes our project better! 🌟


⚠️ 由于长期无活动,此 issue 已被自动关闭。

  • 如果这个问题对您来说仍然重要,您可以:
    1. 重新打开并提供补充信息
    2. 创建一个新的 issue 并更新相关背景
    3. 关联相关的 issue 或讨论

为了更好地维护项目,我们需要定期清理不活跃的问题。

感谢您为开源添砖加瓦!🌟

posted by github-actions[bot] about 1 month ago

Fund this Issue

$0.00
Funded

Pull requests