Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@keyvaluesystems/react-dot-matrix-chart
Advanced tools
A customizable ready to use Dot Matrix Chart Component for React
Try tweaking a dot matrix using this codesandbox link here
The easiest way to use react-dot-matrix-chart is to install it from npm and build it into your app with Webpack.
npm install react-dot-matrix-chart
You’ll need to install React separately since it isn't included in the package.
React Dot Matrix Chart can run in a very basic mode by just providing the dataPoints
like given below:
import DotMatrix from 'react-dot-matrix-chart';
<DotMatrix
dataPoints={dataPointsArray}
/>
The datapoints is an array of objects with the following keys:
name
- a string that represents each category
count
- a number to specify the count of each category present(used to find the number of dots to be displayed)
color
- a string to specify which colour to be used to represent the category in the dot matrix
An example for dataPoints array is shown below:
const dataPointsArray = [
{
name: 'Category 1',
count: 10,
color: 'gray'
},
{
name: 'Category 2',
count: 10,
color: 'black'
},
{
name: 'Category 3',
count: 10,
color: 'green'
}
];
You can specify the number of rows or columns to be present in the chart as well using the dimensions prop.
<DotMatrix
dataPoints={dataPointsArray}
dimensions={
rows: 5,
columns: 10
}
/>
If the count given in the dataPoints array results in a partial percentage (decimal value), a gradient dot will be displayed as shown below
We can also control the display of the legend consisting of the details regarding the colour distribution using the props 'showLegend' and 'legendPosition' as follows.
<DotMatrix
dataPoints={dataPointsArray}
showLegend={true}
legendPosition="top"
/>
Props that can be passed to the component are listed below:
Prop | Description | Default |
---|---|---|
dataPoints: object[] | An array of category objects to specifying the count and name of each section | undefined |
dimensions?: object | To specify the number of rows and columns to be present in the chart | { rows: 5, columns: 12 } |
styles?: object | Provides you with a bunch of callback functions to override the default styles. | undefined |
showLegend?: boolean | To specify whether to show the legend or not | false |
legendPosition?: string | To specify the position of the legend. The values that can be passed using this prop are 'left', 'right', 'top' and 'bottom' | right |
All the default styles provided by this package are overridable using the styles
prop.
the below code shows all the overridable styles:
<DotMatrix
dataPoints={dataPointsArray}
styles={{
Container: () => ({...styles}),
DotsContainer: () => ({...styles}),
Dot: () => ({...styles}),
LegendContainer: () => ({...styles}),
LegendName: () => ({...styles}),
LegendDot: () => ({...styles})
}}
/>
Container
- overrides the dot matrix chart container styleDotsContainer
- overrides the dot matrix chart dots container styleDot
- overrides the style of each dot in the chartLegendContainer
- overrides the legend (details) container styleLegendName
- overrides the legend name styleLegendDot
- overrides the legend dot styleFAQs
A Dot Matrix Chart component
We found that @keyvaluesystems/react-dot-matrix-chart demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.