ant-design / ant-design-charts

A React Chart Library
https://ant-design-charts.antgroup.com/
MIT License
1.95k stars 364 forks source link

🐛[BUG] Donut圆环图value为null #96

Closed kiwenlau closed 4 years ago

kiwenlau commented 4 years ago

🐛 bug 描述

image

📷 复现步骤

仓库:https://github.com/kiwenlau/g2plot-donut-demo 直接运行即可

🏞 期望结果

截屏2020-07-02 上午10 02 50

💻 复现代码

仓库:https://github.com/kiwenlau/g2plot-donut-demo

我用setTimeout模拟了HTTP请求,核心代码如下:

import React, { useEffect, useState } from "react";
import { Donut } from "@ant-design/charts";

const setTimeoutPromise = ms => new Promise(resolve => setTimeout(resolve, ms));

export default function App(props) {
  const [data, setData] = useState([]);
  const { time } = props;

  useEffect(() => {
    const fetchData = async () => {
      const res = await setTimeoutPromise(time).then(() => [
        {
          type: "Google",
          value: 25
        },
        {
          type: "Facebook",
          value: 25
        },
        {
          type: "Alibaba",
          value: 25
        },
        {
          type: "Tencent",
          value: 25
        }
      ]);
      setData(res);
    };
    fetchData();
  }, [time]);

  const config = {
    forceFit: true,
    radius: 0.8,
    data,
    angleField: "value",
    colorField: "type"
  };

  return (
    <div className="App">
      <Donut {...config} />
    </div>
  );
}

© 版本信息

🚑 其他信息

应该是@antv/g2plot@1.1.8导致的BUG,我通过package-lock.json将@antv/g2plot的版本锁定为1.1.7时就没有问题了

lxfu1 commented 4 years ago

这个是依赖问题,G2Plot 下个版本修复。

afc163 commented 4 years ago

修复了么?

liujiayu10 commented 4 years ago

修复了么?

还没有修复,唉

lxfu1 commented 4 years ago

你更新试试呢,这个是依赖的 bug , 依赖已经发布新版本。

liujiayu10 commented 4 years ago

你更新试试呢,这个是依赖的 bug , 依赖已经发布新版本。

谢谢大大!

kiwenlau commented 4 years ago

我确认了一下,问题已修复:

npm list | grep @ant-design/charts
├─┬ @ant-design/charts@0.9.10 

npm list | grep g2plot 
│ ├─┬ @antv/g2plot@1.1.22