
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
js-color-gradient
Advanced tools
js-color-gradient helps you get gradient colors for your web application.Like in table , list etc.It gives result in an array of colors. It allows you to configure options like color, fromColor, toColor, style. Currently it takes gradient steps based on the range provided.Like for range '0-20' gradient steps will be 20.
To build the examples locally with npm, run:
npm install
npm start
Then localhost:3000 should open in a browser. If not you can go to that directly.
To use js-color-gardient, install it from NPM with npm using the command:
npm install --save js-color-gradient
To use js-color-gradient, install it from yarn using the command:
yarn add js-color-gradient
To use this component, first import js-color-gradient:
import {getColors} from 'js-color-gradient';
and then provide it the options.
let options = [{
style: 'gradient',
range: '0-20',
fromColor: '#8B0000',
toColor: '#FFCCCB'
},
{
style: 'gradient',
range: '21-40',
fromColor: '#8B8000',
toColor: '#FFFFE0'
},
{
style: 'gradient',
range: '41-100',
fromColor: '#0000ff',
toColor: '#ADD8E6'
}];
let data = [{
item: 'item1',
count: 1,
percentage: 1
},
{
item: 'item2',
count: 2,
percentage: 2
},
{
item: 'item3',
count: 3,
percentage: 3
},
{
item: 'item4',
count: 4,
percentage: 4
},
{
item: 'item5',
count: 5,
percentage: 5
},
{
item: 'item6',
count: 6,
percentage: 6
},
{
item: 'item7',
count: 7,
percentage: 7
},
{
item: 'item8',
count: 8,
percentage: 8
},
{
item: 'item9',
count: 9,
percentage: 9
},
{
item: 'item10',
count: 10,
percentage: 10
}];
let gradientColorForTable = getColors(options);
let tableData = data;
return (
<div>
<table>
<thead>
<tr>
<td><h4>Item</h4></td>
<td><h4>Count</h4></td>
<td><h4>Percentage</h4></td>
</tr>
</thead>
<tbody>
{tableData.map((data, i) => (
<tr key={i+1}>
<td>
{data.item}
</td>
<td>
{data.count}
</td>
<td style={{ backgroundColor: gradientColorForTable[data.percentage]}}>
{data.percentage}
</td>
</tr>
))}
</tbody>
</table>
</div>
);
}
export default App;
If style is 'gradient':
{
style: 'gradient',
range: '0-20',
fromColor: '#8B0000',
toColor: '#FFCCCB'
}
If style is 'constant':
{
style: 'constant',
range: '0-20',
color: '#8B0000'
}
You can provide as many range as you want and style also can be given same or different as per the requirement.
You can take a look at the example given in example folder. To run the React Example use npm i then npm start
Fork this repo, add your proposed features and make a pull request. I will review as soon as possible.
This project is licensed under the terms of the MIT license. Check LICENSE.txt for more information.
FAQs
This project hepls to get color gradient code based on value.
We found that js-color-gradient demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.