Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

Bizcharts使用value属性报错

使用AntV的react版本图表Bizcharts的仪表盘时遇到问题,无法使用value属性,只要写上value就报错,报错如下图所示

image.png

代码就是官网的源示例代码
仪表盘示例

请问有什么解决的办法吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

workaround:用 antv 的水波图自己写了一个

代码放这里:

import React, {useRef, useEffect} from "react";
import { Liquid } from '@antv/g2plot';

const WaterWave = ({ value }) => {
  const container = useRef(null);

  useEffect(() => {
    if (!container.current) {
      return;
    }
    const liquidPlot = new Liquid(container.current, {
      percent: value,
      height: 200
    });
    liquidPlot.render();
  }, [container]);

  return (
      <div ref={container} />
  );
};
export default WaterWave; 

这是综合几种方案 bundle size 最小的 workaround, 而且UI完全一样。
请参考:https://github.com/alibaba/Bi...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...