1、插件官网:https://www.npmjs.com/package/echarts-liquidfill
2、在项目中安装echarts和echarts-liquidfill
代码语言:javascript复制npm install echarts
npm install echarts-liquidfill
目前安装版本:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bHvx9zrJ-1679034311702)(/upload/2023/03/image-6b5cd80bd2364c31b6aec4ea898d6f00.png)]
3、新建一个WaterChart.tsx文件,引入echarts和echarts-liquidfill
代码语言:javascript复制import { FC, useEffect } from 'react';
import * as echarts from 'echarts';
import 'echarts-liquidfill';
import React from 'react';
const LiquidCharts: FC = () => {
useEffect(() => {
initChart();
});
const initChart = () => {
const liquid = document.getElementById('main');
const map = echarts.init(liquid as HTMLDivElement);
const option = {
series: [
{
type: 'liquidFill',
data: [0.6, 0.5, 0.4, 0.3],
animationDuration: 0,
animationDurationUpdate: 2000,
animationEasingUpdate: 'cubicOut',
},
],
};
map.clear()
map.setOption(option);
};
return <div id='main' style={{ width: 800, height: 800 }} />;
};
export default LiquidCharts;
4、在需要展示的地方引入WaterChart文件就可以了
代码语言:javascript复制import WaterChart from './WaterChart.tsx'
代码语言:javascript复制<WaterChart />
5、结果展示
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-iMigiZ45-1679034311703)(/upload/2023/03/image-d6c31d9f276645618e11f7edaad0bc41.png)]