'Wave animation of react-liquid-gauge not working
I have installed this https://www.npmjs.com/package/react-liquid-gauge package into my reactjs application and it was working fine for some time but recently the wave animation has stopped working. I changed my computer and now this issue emerged. My nodejs version is 16.13.1. My npm version is 8.1.2. Installing packages with simple npm i is not possible as it gives a dependency error. So I use npm i --legacy-peer-deps or npm i --force. I am also attaching my package.json file content so that you can see if any other package is causing this issue.
{
"name": "@minimal/material-kit-react",
"author": "minimals.cc",
"licence": "MIT",
"version": "1.2.0",
"private": false,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint --ext .js,.jsx ./src",
"lint:fix": "eslint --fix --ext .js,.jsx ./src"
},
"resolutions": {
"react-error-overlay": "6.0.9"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"babel": {
"presets": [
"@babel/preset-react"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"dependencies": {
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@iconify/icons-ant-design": "^1.1.0",
"@iconify/icons-eva": "^1.1.0",
"@iconify/icons-ic": "^1.1.10",
"@iconify/react": "^3.0.1",
"@mui/icons-material": "^5.2.5",
"@mui/lab": "^5.0.0-alpha.47",
"@mui/material": "^5.0.0",
"@mui/utils": "^5.0.0",
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/jest-dom": "^5.14.1",
"apexcharts": "^3.28.3",
"axios": "^0.24.0",
"change-case": "^4.1.2",
"d3-color": "^3.0.1",
"date-fns": "^2.24.0",
"faker": "^5.5.3",
"formik": "^2.2.9",
"framer-motion": "^4.1.17",
"history": "^5.0.1",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"numeral": "^2.0.6",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-apexcharts": "^1.3.9",
"react-d3-cloud": "^1.0.5",
"react-dom": "^17.0.2",
"react-drop-zone": "^4.3.2",
"react-helmet-async": "^1.1.2",
"react-liquid-gauge": "^1.2.4",
"react-notifications-component": "^3.4.1",
"react-redux": "^7.2.6",
"react-router-dom": "^6.0.0-beta.4",
"react-scripts": "^4.0.1",
"redux": "^4.1.2",
"redux-persist": "^6.0.0",
"simplebar": "^5.3.5",
"simplebar-react": "^2.3.5",
"web-vitals": "^2.1.0",
"xlsx": "^0.17.5",
"yup": "^0.32.9"
},
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/eslint-parser": "^7.15.7",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^6.0.1",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.25.2",
"eslint-plugin-react-hooks": "^4.2.0",
"prettier": "^2.4.1"
}
}
here is my component
import
* as React from 'react';
import { color } from 'd3-color';
import LiquidFillGauge from 'react-liquid-gauge';
export default function LiquidTank() {
const [value, setValue] = React.useState(50);
const radius = 200;
const fillColor = '#dc143c';
const gradientStops = [
{
key: '0%',
stopColor: color(fillColor).darker(0.5).toString(),
stopOpacity: 1,
offset: '0%'
},
{
key: '50%',
stopColor: fillColor,
stopOpacity: 0.75,
offset: '50%'
},
{
key: '100%',
stopColor: color(fillColor).brighter(0.5).toString(),
stopOpacity: 0.5,
offset: '100%'
}
];
return (
<div
className="position-relative"
style={{
maxWidth: '317px'
}}
>
<LiquidFillGauge
style={{ margin: '0 auto' }}
width={radius * 2}
height={radius * 2}
value={value}
percent="%"
textSize={1}
textOffsetX={0}
textOffsetY={0}
textRenderer={(props) => {
const value = Math.round(props.value);
const radius = Math.min(props.height / 2, props.width / 2);
const textPixels = (props.textSize * radius) / 2;
const valueStyle = {
fontSize: textPixels
};
const percentStyle = {
fontSize: textPixels * 0.6
};
return (
<tspan>
<tspan className="value" style={valueStyle}>
{value}
</tspan>
<tspan style={percentStyle}>{props.percent}</tspan>
</tspan>
);
}}
riseAnimation
waveAnimation
waveFrequency={2}
waveAmplitude={1}
gradient
gradientStops={gradientStops}
circleStyle={{
fill: fillColor
}}
waveStyle={{
fill: fillColor
}}
textStyle={{
fill: color('#444').toString(),
fontFamily: 'Arial'
}}
waveTextStyle={{
fill: color('#fff').toString(),
fontFamily: 'Arial'
}}
/>
</div>
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
