Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
d3-tagcloud-for-react
Advanced tools
Readme
Another tag cloud for react with two variable fontSize and opacity, using the wonderful d3-cloud under the hood.
$ npm install d3-tagcloud-for-react
import React, { Component } from 'react'
import TagCloud, {renderData} from 'd3-tagcloud-for-react';
const colorarray = [
'#8c5fc4',
'#61b8ff',
'#f7d286',
'#e86971',
'#76bb7f',
'#5bbeca',
]
const data = [
{
label: 'React',
fontSize: 10,
opacity: 8,
color:'blue'
},
{
label: 'jQuery',
fontSize: 9,
opacity: 9,
},
{
label: 'ECMAScript 6',
fontSize: 4,
opacity: 7,
},
{
label: 'webpack',
fontSize: 4,
opacity: 4,
},
{
label: 'Redux',
fontSize: 4,
opacity: 7,
},
{
label: 'HTML5',
fontSize: 9,
opacity: 9,
},
{
label: 'JSON APIs',
fontSize: 9,
opacity: 6,
},
{
label: 'JavaScript',
fontSize: 9,
opacity: 8,
},
{
label: 'CSS3',
fontSize: 9,
opacity: 9,
},
{
label: 'PHP',
fontSize: 8,
opacity: 3,
},
{
label: 'MySQL',
fontSize: 8,
opacity: 4,
},
{
label: 'WordPress',
fontSize: 9,
opacity: 8,
},
{
label: 'Github',
fontSize: 6,
opacity: 5,
},
{
label: 'SASS',
fontSize: 6,
opacity: 6,
},
{
label: 'Node.js',
fontSize: 4,
opacity: 4,
},
{
label: 'JSX',
fontSize: 8,
opacity: 5,
},
{
label: 'SEO',
fontSize: 9,
opacity: 8,
},
{
label: 'Redux Saga',
fontSize: 4,
opacity: 6,
},
{
label: 'Immutable',
fontSize: 4,
opacity: 5,
},
{
label: 'CSS Javascript',
fontSize: 4,
opacity: 6,
},
{
label: 'GraphQL',
fontSize: 1,
opacity: 4,
},
]
class DemoCloud extends Component {
render() {
return (
<TagCloud
className='tag-cloud'
// rotate={() => Math.round(Math.random() * 180)}
// spiral={1}
style={{
fontFamily: 'sans-serif',
// fontSize: () => Math.round(Math.random() * 50) + 16,
fontSize: 30,
// color: () => randomColor(colorarray),
padding: 5,
width: '100%',
height: '600px',
}}
data={data}
colorarray={colorarray}
>
{renderData(data)}
<div
style={{
fontSize: 30,
fontWeight: 'bold',
opacity: 0.9,
padding: 12,
color: 'black'
}}
>
Black
</div>
</TagCloud>
);
}
}
<TagCloud>
propsname | description | type | default |
---|---|---|---|
style.fontSize | Font size needed for calculating layout | Function/Number | 30 |
style.fontFamily | Font family needed for calculating layout | Function/String | serif |
style.fontWeight | Font weight needed for calculating layout | Function/Number | normal |
style.fontStyle | Font style needed for calculating layout | Function/String | normal |
style.padding | Padding between tags (px) | Function/Number | 10 |
style.color | Color to be used by tags | Function/String | randomColor |
rotate | Rotation in degrees | Function/Number | 0 |
colorarray | Color Palette | Array | null |
data | Tags Array | Array | null |
random | Randomizer function | Function | Math.random |
<TagCloud>
child component propsYou can create or use any component as a child component. TagCloud
looks for the following props for its layout calculation:
name | description | type | default |
---|---|---|---|
style.fontSize | Font size needed for calculating layout | Function/Number | 30 |
style.fontFamily | Font family needed for calculating layout | Function/String | serif |
style.fontWeight | Font weight needed for calculating layout | Function/Number | normal |
style.fontStyle | Font style needed for calculating layout | Function/String | normal |
style.opacity | Opacity for Tags | Function/Number | 1 |
style.padding | Padding between tags (px) | Function/Number | 10 |
style.color | Color to be used by tag | Function/String | (none) |
rotate | Rotation in degrees | Function/Number | 0 |
FAQs
Another tag cloud for react using d3-cloud
The npm package d3-tagcloud-for-react receives a total of 4 weekly downloads. As such, d3-tagcloud-for-react popularity was classified as not popular.
We found that d3-tagcloud-for-react 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.