Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-liquid-gauge
Advanced tools
React Liquid Gauge component. It's heavily inspired by D3 Liquid Fill Gauge and react-liquidchart.
Demo: http://trendmicro-frontend.github.io/react-liquid-gauge
The sample code can be found in the examples directory.
npm install --save react react-dom react-liquid-gauge
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import LiquidFillGauge from 'react-liquid-gauge';
const rgbcolor = (value) => {
const startColor = {
red: 0x64,
green: 0x95,
blue: 0xed
};
const endColor = {
red: 0xdc,
green: 0x14,
blue: 0x3c
};
const diffRed = endColor.red - startColor.red;
const diffGreen = endColor.green - startColor.green;
const diffBlue = endColor.blue - startColor.blue;
const percentFade = value / 100;
return [
Math.floor(diffRed * percentFade) + startColor.red,
Math.floor(diffGreen * percentFade) + startColor.green,
Math.floor(diffBlue * percentFade) + startColor.blue
];
};
class App extends Component {
state = {
value: Math.round(Math.random() * 100)
};
render() {
const fillColor = `rgb(${rgbcolor(this.state.value).join(',')})`;
return (
<div>
<LiquidFillGauge
animate
onAnimationProgress={(options) => {
const { value, outerArc, liquid } = options;
const fillColor = `rgb(${rgbcolor(value).join(',')})`;
outerArc.attr('fill', fillColor);
liquid.attr('fill', fillColor);
}}
outerArcStyle={{
fill: fillColor
}}
liquidStyle={{
fill: fillColor
}}
liquidNumberStyle={{
fill: 'rgb(255, 255, 255)'
}}
numberStyle={{
fill: 'rgb(0, 0, 0)'
}}
width={240}
height={240}
style={{ margin: '0 auto' }}
value={this.state.value}
textOffsetX={0}
textOffsetY={0}
onClick={() => {
this.setState({ value: Math.random() * 100 });
}}
/>
<div
style={{
margin: '20px auto',
width: 120
}}
>
<button
type="button"
className="btn btn-default btn-block"
onClick={() => {
this.setState({ value: Math.random() * 100 });
}}
>
Refresh
</button>
</div>
</div>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('container')
);
Name | Type | Default | Description |
---|---|---|---|
value | Number | 100 | |
animate | Boolean | false | |
onAnimationProgress | Function(options) | ||
onAnimationEnd | Function(options) | ||
onClick | Function(event) | ||
outerRadius | Number | 1.0 | |
innerRadius | Number | 0.9 | |
margin | Number | 0.025 | |
ease | Function | ||
animationTime | Number | 2000 | |
amplitude | Number | 1 | |
frequency | Number | 5 | |
outerArcStyle | Shape | { fill: 'rgb(23, 139, 202)' } | |
liquidStyle | Shape | { fill: 'rgb(23, 139, 202)' } | |
liquidNumberStyle | Shape | { fill: 'rgb(164, 219, 248)' } | |
numberStyle | Shape | { fill: 'rgb(4, 86, 129)' } | |
offsetX | Number | 1 | |
offsetY | Number | 1 | |
textSize | Number | 1 | |
textOffsetX | Number | 0 | |
textOffsetY | Number | 0 | |
percentageSymbol | String | % |
FAQs
React Liquid Gauge component
The npm package react-liquid-gauge receives a total of 1,647 weekly downloads. As such, react-liquid-gauge popularity was classified as popular.
We found that react-liquid-gauge demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.