
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
react-chartlet
Advanced tools
A dead simple and tiny React charting library
yarn add react-chartlet
Please note that all charts are responsive by default; they will grow to fill the width of their container, and have height set to 100%
. You can set a specific size on them, however if you don't your chart may not show up due to it's height being 0.
import { Sparkline } from 'react-chartlet'
const YourPage = () => (
<Sparkline
data={[2, 5, 3, 8, 1]}
height="100px"
/>
)
export default YourPage
import { Donut } from 'react-chartlet'
const MyPage = () => (
<Donut
data={[2, 5, 3]}
height="100px"
/>
)
import { Donut, Legend } from 'react-chartlet'
const MyPage = () => {
const data = [
{ label: 'Carrots', value: 3 },
{ label: 'Tomatoes', value: 5 },
{ label: 'Potatoes', value: 2 },
]
return (
<div style={{ display: 'flex', gap: '2em' }}>
<Donut
data={data.map(row => row.value)}
height="100px"
/>
<Legend
data={data.map(row => row.value)}
labels={data.map(row => row.label)}
/>
</div>
)
}
export default YourPage
Property | Type | Default | Description |
---|---|---|---|
data | array | [] | An array of numbers |
width | string | - | CSS width of your chart |
height | string | 100% | CSS height of your chart |
min | number | smallest datapoint in data array | The minimum value on the y axis |
max | number | largest datapoint in data array | The maximum value on the y axis |
margin | number or object | { top: 5, bottom: 5 } | Margin between the border of the chart and the line, either as a number to set all sides, or an object to set specific sides, like { top: 5, right: 5, bottom: 5, left: 5 } |
style | object | {} | Directly set the style object of the svg container |
lineStyle | object | {} | Set the style object of the line |
tooltip | object | {} | An object with two functions, handle and close |
Property | Type | Default | Description |
---|---|---|---|
data | array | [] | An array of numbers |
width | string | - | CSS width of your chart |
height | string | 100% | CSS height of your chart |
colors | array | The colors.CATEGORICAL palette | CSS colours used for each data point |
style | object | {} | Directly set the style object of the svg container |
offset | number | 0 | Set the rotation offset between 0 and 1 |
hole | number | 0.5 | Donut hole size as a portion of the diameter |
segmentStyle | object | {} | Set the style object of all donut segments |
segmentStyles | array | - | Set the styles used for each donut segments |
Property | Type | Default | Description |
---|---|---|---|
data | array | [] | An array of numbers, should match your chart |
labels | array | [] | An array of strings, in the same order as your data array |
colors | array | the colors.CATEGORICAL palette | CSS colours used for each data point |
bulletSize | string | 15px | The size of the colour bullets |
labelStyle | object | {} | Set the style object of all labels |
percentageStyle | object | {} | Set the style object of all percentage labels |
To test the components in this library, follow the steps below:
yarn
to install dependenciesyarn storybook
to start StorybookYou can set up stories to test components using this documentation
FAQs
A dead simple and tiny charting library for React
The npm package react-chartlet receives a total of 0 weekly downloads. As such, react-chartlet popularity was classified as not popular.
We found that react-chartlet 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.