antvis/G2

TypeError: Cannot create property 'lineStyle' on boolean 'false' #4058

xbzhang2020 posted onGitHub

  • I have searched the issues of this repository and believe that this is not a duplicate.

https://stackblitz.com/edit/vitejs-vite-qdhzkz?file=main.js,index.html

Steps to reproduce

打开浏览器控制台即可看到报错。

<img width="1738" alt="截屏2022-08-01 17 52 48" src="https://user-images.githubusercontent.com/39360445/182127000-3318ef16-ff5a-4e64-a808-b6e420b14154.png">

Environment Info
g2 3.5.19
System OS: macOS 12.4
Browser Chrome: 103.0.5060.134

在Vite中使用@antv/g2,折线图的tooltip无法正常加载,并且浏览器控制台报错。 已经定位到问题:tooltip.crosshairs的初始值为false,会执行g2内部的_mix方法,在严格模式下会抛出错误。 <img width="852" alt="截屏2022-08-01 17 28 46" src="https://user-images.githubusercontent.com/39360445/182126715-de27e3ab-3e08-4743-ba1d-18a15279dabe.png">

<img width="1662" alt="截屏2022-08-01 17 28 03" src="https://user-images.githubusercontent.com/39360445/182126875-2d54b79c-c387-4838-9620-f6fb5f535c22.png">

希望能尽快解决这一问题。

<!-- generated by antv-issue-helper. DO NOT REMOVE -->


@xbzhang2020 已经定位到问题了,有兴趣来提交 pr 吗?另外,可以尽快调研迁移到新版本了。

posted by hustcc over 2 years ago

好的,我提个PR。

posted by xbzhang2020 over 2 years ago

请问这个bug是在哪个版本里面修复的呢?

posted by wangzhengbo over 1 year ago

好的,我提个PR。

麻烦问题是哪个PR修复的呀?

posted by wangzhengbo over 1 year ago

好的,我提个PR。

屁事不干,到现在还有这个问题

posted by LiMao00 over 1 year ago

这个问题到现在还存在,尝试切换成 canvas 渲染模式,发现 canvas 模式比 html 模式效果差很多。目前没找到办法可以规避

posted by AlphaCodeZero over 1 year ago

这个问题不好修复,真正出错的地方应该在g2的一个依赖的@antv/util包中,就搁置了。如果遇到同类问题,可以使用 patch-package 工具给这个包打个补丁,自己就是这么解决的。期待有能力的大佬修复这个问题吧。

posted by xbzhang2020 over 1 year ago

这个问题不好修复,真正出错的地方应该在g2的一个依赖的@antv/util包中,就搁置了。如果遇到同类问题,可以使用 patch-package 工具给这个包打个补丁,自己就是这么解决的。期待有能力的大佬修复这个问题吧。

具体修复代码是?

posted by youthug 11 months ago

可以自己临时处理下,对Tooltip做下封装,代码中都使用自己定义的Tooltip.

import React from "react";
// eslint-disable-next-line no-restricted-imports
import { Tooltip } from "viser-react";

type ViserTooltipProps = Tooltip["props"];

const ViserTooltip: React.FC<ViserTooltipProps> = (props) => {
  // crosshairs设置为空字符串是为了兼容vite: https://github.com/antvis/G2/issues/4058
  return <Tooltip {...props} {...("crosshairs" in props ? {} : { crosshairs: "" })} />;
};

export default ViserTooltip;
posted by wangzhengbo 11 months ago

Fund this Issue

$0.00
Funded

Pull requests