npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-svg-donuts

v3.0.0

Published

A ReactJS component for simple SVG donut graphs.

Downloads

771

Readme

Travis CI Github Build Codacy Badge Codebeat Badge CodeFactor Badge DeepScan grade Analytics

React SVG Donuts

A React component for simple (and complex) SVG donuts.

The current version depends on the Hooks API introduced with React 16.8. If you need legacy React support, please use a 1.x.x version.

Visitor stats

GitHub stars GitHub forks GitHub watchers GitHub followers

Code stats

GitHub code size in bytes GitHub repo size GitHub language count GitHub top language GitHub last commit

Demo

TL;DR here is the demo

Dependencies

  1. NodeJS
  2. NPM / Yarn
  3. React and ReactDOM
  4. A ReactJS application

Usage

First install the package

$ npm i react-svg-donuts

# or

$ yarn add react-svg-donuts

Then

import React from 'react';

import { Donut, ComplexDonut } from 'react-svg-donuts';

// The donut will be half filled
const progress = 50;

// The value will be wrapped inside a <strong> tag.
const renderProgress = progress => <strong>{progress}%</strong>;

const MyComponent = () => (
	<>
		<Donut progress={progress} onRender={renderProgress} />, document.getElementById('demo')
		<ComplexDonut
			size={200}
			parts={[
				{
					color: '#FF8A80',
					value: 230
				},
				{
					color: '#FF80AB',
					value: 308
				},
				{
					color: '#B9F6CA',
					value: 520
				},
				{
					color: '#B388FF',
					value: 130
				},
				{
					color: '#8C9EFF',
					value: 200
				}
			]}
			radius={80}
			thickness={40}
			startAngle={-90}
		/>
	</>
);

Props

Donut props

| Prop | Type | Required | Default | Description | | ---------- | ---------- | -------- | ----------------------------------------- | ----------------------------------------------------------------------- | | prefix | string | false | 'donut' | String used as a prefix for the CSS class names | | progress | number | false | 0 | A number between 0 and 100 | | onRender | Function | false | (progress) => {progress} | Function which runs after the Donut is rendered and returns a ReactNode |

Complex donut props

| Prop | Type | Required | Default | Description | | ----------- | ----------------------------------- | -------- | ------- | ------------------------------------------- | | size | number | false | 160 | The width and height of the donut | | parts | { color: string; value: number; }[] | false | [] | The donut parts | | radius | number | false | 60 | The radius of the element | | className | string | false | '' | Custom CSS class name for the Donut | | thickness | number | false | 30 | Stroke width of the element | | textProps | SVGProps for SVGTextElement | false | {} | Additional props for the element | | startAngle | number | false | -90 | Number between -360 and 360 | | circleProps | SVGProps for SVGCircleElement | false | {} | Additional props for the element |

CSS

There is a predefined stylesheet which can be used as is. If you want it, just import it:

@import 'react-svg-donuts/src/index.css';

or

import 'react-svg-donuts/src/index.css';

LICENSE

MIT