antvis/G2

切换浏览器标签页后切换回来后图表显示空白 #3811

ckvv posted onGitHub

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

切换浏览器标签页后切换回来后图表显示空白, 鼠标hover后才显示

Reproduction

https://codepen.io/chenkai0520/full/OJjGEQK

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>折线图-issue</title>
</head>

<body>
  <div id="container" style="width: 1079px; height: 312px;"></div>
  <script src="https://gw.alipayobjects.com/os/lib/antv/g2/4.1.32/dist/g2.min.js"></script>
  <script>
    const data = [{
        date: '2021-11-19',
        value: 995.023
      },
      {
        date: '2021-11-18',
        value: 1021.899
      },
      {
        date: '2021-11-17',
        value: 948.366
      },
      {
        date: '2021-11-16',
        value: 947.162
      },
      {
        date: '2021-11-15',
        value: 1003.01
      },
      {
        date: '2021-11-14',
        value: 1072.513
      },
      {
        date: '2021-11-13',
        value: 1164.065
      }
    ];
    const chart = new G2.Chart({
      container: 'container',
      autoFit: true,
    });

    chart.data(data);
    chart.scale({
      date: {
        range: [0, 1],
      },
      value: {
        min: 0,
        nice: true,
      },
    });

    chart.tooltip({
      showCrosshairs: true, // 展示 Tooltip 辅助线
      shared: true,
    });

    chart.line().position('date*value').label('value');
    chart.point().position('date*value');
    chart.render();
  </script>
</body>

</html>

<img width="1431" alt="截屏2022-02-16 下午3 20 23" src="https://user-images.githubusercontent.com/30174970/154215516-80568fde-e2e7-49b2-ad7d-218e6d87bf68.png">

Environment Info
g2 4.1.34
System MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)
Browser Google Chrome 版本 98.0.4758.80(正式版本) (x86_64)


有可能是浏览器的原因,这个问题我只在谷歌浏览器上复现了

posted by ckvv about 3 years ago

我在 chrome 似乎没问题(可能我没有升级 chrome)

posted by visiky about 3 years ago

@visiky 是Chrome的问题,echarts 也发现了同样的问题, 包括下面的代码在浏览器中切换标签页后也不正常

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <canvas id="canvas"></canvas>
</body>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');

ctx.fillStyle = 'green';
ctx.fillRect(10, 10, 150, 100);
</script>
</html>
posted by ckvv about 3 years ago
posted by ckvv about 3 years ago

Fund this Issue

$0.00
Funded

Pull requests