antvis/G2

Do you want to work on this issue?

You can request for a bounty in order to promote it!

[Bug]: 分组柱图,如果某个值为null,在tooltips为shared情况下,没有该值的提示 #6754

sanye-huang posted onGitHub

Describe the bug / 问题描述

测试代码

import { Chart } from "@antv/g2";

const chart = new Chart({ container: "container" });

chart.options({
  type: "interval",
  autoFit: true,
  data: [
    { name: "London", 月份: "Jan.", 月均降雨量: 18.9 },
    { name: "London", 月份: "Feb.", 月均降雨量: 28.8 },
    { name: "London", 月份: "Mar.", 月均降雨量: 39.3 },
    { name: "London", 月份: "Apr.", 月均降雨量: null },
    { name: "London", 月份: "May", 月均降雨量: 47 },
    { name: "London", 月份: "Jun.", 月均降雨量: 20.3 },
    { name: "London", 月份: "Jul.", 月均降雨量: 24 },
    { name: "London", 月份: "Aug.", 月均降雨量: 35.6 },
    { name: "Berlin", 月份: "Jan.", 月均降雨量: 12.4 },
    { name: "Berlin", 月份: "Feb.", 月均降雨量: 23.2 },
    { name: "Berlin", 月份: "Mar.", 月均降雨量: 34.5 },
    { name: "Berlin", 月份: "Apr.", 月均降雨量: 99.7 },
    { name: "Berlin", 月份: "May", 月均降雨量: 52.6 },
    { name: "Berlin", 月份: "Jun.", 月均降雨量: 35.5 },
    { name: "Berlin", 月份: "Jul.", 月均降雨量: 37.4 },
    { name: "Berlin", 月份: "Aug.", 月均降雨量: null },
  ],
  encode: { x: "月份", y: "月均降雨量", color: "name" },
  transform: [{ type: "dodgeX" }],
  interaction: {
    tooltip: {
      shared: true
    }, elementHighlight: { background: true }
  },
});

chart.render();

实际

Image 期望

Image

No response

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

No response

Version / 版本

🆕 5.x

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

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

@moayuisuda 是不是之前有一个 pr 有做 item 的过滤吗?

posted by hustcc 18 days ago

https://github.com/antvis/G2/issues/6699

我觉得应该是这个 pr 的问题,当时的设计是如果 value 是 null 时,数据直接不展示。https://github.com/antvis/G2/issues/6699#issuecomment-2750014919

posted by BQXBQX 17 days ago

我觉得应该是这个 pr 的问题,当时的设计是如果 value 是 null 时,数据直接不展示。#6699 (comment)

之前是显示异常,这么看,还是要显示 null 的。

posted by hustcc 17 days ago

正常情况 <img width="1312" alt="Image" src="https://github.com/user-attachments/assets/fc522a16-9401-474e-88ae-be7e5e484db6" />

异常情况 <img width="1312" alt="Image" src="https://github.com/user-attachments/assets/e2e0d3fc-23fd-4205-8f75-57b54ed2e710" />

可能需要一些特殊处理,现在的 data 是从 element 对象拿到的,但是当 值为 null,对应的 element 貌似不存在,所以拿不到这个对应的 data,导致 tooltip 无法正常渲染。

posted by BQXBQX 17 days ago

I believe I might a solution to your problem. Check it out here click

posted by horlegsimpSon 10 days ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests